Skip to content

Commit

Permalink
Merge pull request #1 from perl5577/master
Browse files Browse the repository at this point in the history
Add function for listing incoming_transfer Option : all,available,unavailable
  • Loading branch information
netmonk committed Mar 2, 2015
2 parents 9d2d25f + 82f4962 commit 63d4f1e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
17 changes: 14 additions & 3 deletions moneronjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Wallet(ip,port){
self.getaddress = function (callback){
rpc(self.opt.ip, self.opt.port, "getaddress",'', function(error,result){
if (error){
console.log("error in getting address"+error);
console.log("error in getting address: %j", [error]);
return;
} else { //console.log(result)
var address = result.address;
Expand All @@ -85,7 +85,7 @@ function Wallet(ip,port){
self.getbalance = function(callback){
rpc(self.opt.ip, self.opt.port, "getbalance",'', function(error,result){
if (error){
console.log("error in getting balance"+error);
console.log("error in getting balance: %j", [error]);
return;
} else {//console.log(result)
var unlocked = result.unlocked_balance;
Expand All @@ -97,13 +97,24 @@ function Wallet(ip,port){
self.getpayment= function(pid, callback){
rpc(self.opt.ip, self.opt.port, "get_payments", { "payment_id" : pid }, function(error,result){
if (error){
console.log("error in getting payment"+error);
console.log("error in getting payment: %j",[error]);
return;
} else {//console.log(result)
callback(result);
}
});
}
self.incoming_transfers= function(type,callback){
rpc(self.opt.ip, self.opt.port, "incoming_transfers", { "transfer_type" : type }, function(error,result){
if (error){
console.log("error in getting incoming_transfers: %j", [ error]);
return;
} else {
callback(result);
}
});
}

}


15 changes: 14 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
var wallet = require('./moneronjs.js');

console.log("this is a wallet rpc interface test");
var wal = new wallet.Wallet("127.0.0.1","10500");
var wal = new wallet.Wallet("127.0.0.1","8082");
console.log(wal.opt);


wal.getaddress(function(address){
console.log("lets try to get the address of the wallet");
console.log(address);
Expand All @@ -23,3 +25,14 @@ wal.getpayment("0000000000000000000000000000000000000000000000000000000000000000
console.log(result);
});

wal.incoming_transfers("available",function(result){
console.log("Listing of TX UnSpend");
console.log(result);
});
wal.incoming_transfers("unavailable",function(result){
console.log("Listing of TX Spend");
console.log(result);
});



0 comments on commit 63d4f1e

Please sign in to comment.