You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.6 KiB

9 years ago
/*!
* Iguana api config
*
*/
var server = {
"protocol": "http://",
"ip": "localhost",
"port": "7778"
};
9 years ago
var apiRoutes = {
"bitcoinRPC" : {
"walletPassphrase" : "bitcoinrpc/walletpassphrase", // params: password String, timeout Int
"encryptWallet" : "bitcoinrpc/encryptwallet" // params: passphrase String
9 years ago
}
};
function getServerUrl() {
return server.protocol + server.ip + ":" + server.port + "/api/";
9 years ago
}
9 years ago
function walletLogin(passphrase) {
var result = false;
$.ajax({
url: getServerUrl() + apiRoutes.bitcoinRPC.walletPassphrase + "?password=" + passphrase + "&timeout=300",
cache: false,
dataType: "text",
async: false
})
.done(function(_response) {
9 years ago
var response = $.parseJSON(_response);
if (response.error) {
// do something
console.log("error: " + response.error);
result = false;
} else {
if (response.result === "success") {
result = true;
} else {
result = false;
}
}
});
return result;
}
function walletCreate(passphrase) {
var result = false;
$.ajax({
url: getServerUrl() + apiRoutes.bitcoinRPC.encryptWallet + "?passphrase=" + passphrase,
cache: false,
dataType: "text",
async: false
})
.done(function(_response) {
var response = $.parseJSON(_response);
9 years ago
if (response.error) {
// do something
console.log("error: " + response.error);
9 years ago
result = false;
} else {
if (response.result === "success") {
result = true;
} else {
result = false;
}
}
});
return result;
}