From e09d4162145708cbafd9f5730b4568593f2d3ecd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Jan 2017 11:11:57 +0200 Subject: [PATCH] importaddress --- iguana/iguana_rpc.c | 6 ++++++ iguana/iguana_wallet.c | 13 +++++++++++++ includes/iguana_apideclares.h | 1 + 3 files changed, 20 insertions(+) diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index 3f0d92a51..cee018046 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -398,6 +398,11 @@ static char *dumpprivkey(RPCARGS) return(sglue1(0,CALLGLUE,"bitcoinrpc","dumpprivkey","address",params[0])); } +static char *importaddress(RPCARGS) +{ + return(sglue3(0,CALLGLUE,"bitcoinrpc","importaddress","address",params[0],"account",params[1],"rescan",params[2])); +} + static char *importprivkey(RPCARGS) { return(sglue3(0,CALLGLUE,"bitcoinrpc","importprivkey","wif",params[0],"account",params[1],"rescan",params[2])); @@ -612,6 +617,7 @@ struct RPC_info { char *name; char *(*rpcfunc)(RPCARGS); int32_t flag0,remotefla { "dumpwallet", &dumpwallet, true, false }, { "importwallet", &importwallet, false, false }, { "importprivkey", &importprivkey, false, false }, + { "importaddress", &importaddress, false, false }, { "getrawtransaction", &getrawtransaction, false, false }, { "createrawtransaction", &createrawtransaction, false, false }, { "validaterawtransaction", &validaterawtransaction, false, true }, diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index a2057e544..4e902696a 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1464,6 +1464,19 @@ FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldperman return(retstr); } +TWOSTRINGS_AND_INT(bitcoinrpc,importaddress,address,account,rescan) +{ + if ( remoteaddr != 0 ) + return(clonestr("{\"error\":\"no remote\"}")); + if ( coin != 0 && coin->notarychain >= 0 && coin->FULLNODE == 0 && address != 0 && account != 0 ) + { + if ( strcmp(address,account) != 0 ) + return(clonestr("{\"error\":\"only special account == address supported\"}")); + else return(_dex_importaddress(myinfo,coin->symbol,address)); + } + return(0); +} + TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan) { bits256 privkey; char *retstr,*str; cJSON *retjson; struct iguana_waddress addr,*waddr; struct iguana_waccount *wacct = 0; uint8_t type,redeemScript[4096]; int32_t len; struct vin_info V; bits256 debugtxid; diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index cd70955cb..cae8b60f4 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -124,6 +124,7 @@ STRING_ARG(bitcoinrpc,backupwallet,filename); STRING_ARG(bitcoinrpc,importwallet,filename); STRING_ARG(bitcoinrpc,getnewaddress,account); TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan); +TWOSTRINGS_AND_INT(bitcoinrpc,importaddress,address,account,rescan); STRING_ARG(bitcoinrpc,dumpprivkey,address); STRING_AND_THREEINTS(bitcoinrpc,listtransactions,account,count,skip,includewatchonly);