From 82f4962559a48dac84d12514e812dcef6da4a313 Mon Sep 17 00:00:00 2001 From: perl5577 Date: Mon, 2 Mar 2015 22:10:25 +0100 Subject: [PATCH] Add function for listing incoming_transfer Option : all,available,unavailable --- moneronjs.js | 17 ++++++++++++++--- test.js | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/moneronjs.js b/moneronjs.js index a6a49b9..2d8c88d 100644 --- a/moneronjs.js +++ b/moneronjs.js @@ -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; @@ -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; @@ -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); + } + }); + } + } diff --git a/test.js b/test.js index 1a05c10..9258d05 100644 --- a/test.js +++ b/test.js @@ -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); @@ -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); +}); + + +