From e4c67ed018e99702aeac1833aa225281b7716a4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 12 Jul 2019 16:57:51 -1100 Subject: [PATCH 1/8] sizeof(ASSETCHAINS_PEGSCCPARAMS)/sizeof(*ASSETCHAINS_PEGSCCPARAMS) --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fbbe4c677..5d6f2722b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1973,7 +1973,7 @@ void komodo_args(char *argv0) } else if ( ASSETCHAINS_SELFIMPORT == "PEGSCC") { - Split(GetArg("-ac_pegsccparams",""), ASSETCHAINS_PEGSCCPARAMS, 0); + Split(GetArg("-ac_pegsccparams",""), sizeof(ASSETCHAINS_PEGSCCPARAMS)/sizeof(*ASSETCHAINS_PEGSCCPARAMS), ASSETCHAINS_PEGSCCPARAMS, 0); if (ASSETCHAINS_ENDSUBSIDY[0]!=1 || ASSETCHAINS_COMMISSION!=0) { fprintf(stderr,"when using import for pegsCC these must be set: -ac_end=1 -ac_perc=0\n"); From bb2a16729cbb72d33359cd35f7b860dc1f80c412 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 13 Jul 2019 03:29:54 -1100 Subject: [PATCH 2/8] Revert to coquicash magic, fix disable bits setting --- src/komodo_utils.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ab58326af..a9a06c80f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1905,13 +1905,15 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_CC != 0 ) { + uint8_t prevCCi = 0; ASSETCHAINS_CCLIB = GetArg("-ac_cclib",""); Split(GetArg("-ac_ccenable",""), sizeof(ccenables)/sizeof(*ccenables), ccenables, 0); for (i=nonz=0; i<0x100; i++) { - if ( ccenables[i] != 0 ) + if ( ccenables[i] != prevCCi && ccenables[i] != 0 ) { nonz++; + prevCCi = ccenables[i]; fprintf(stderr,"%d ",(uint8_t)(ccenables[i] & 0xff)); } } @@ -1923,11 +1925,12 @@ void komodo_args(char *argv0) ASSETCHAINS_CCDISABLES[i] = 1; SETBIT(disablebits,i); } - for (i=0; i<256; i++) + for (i=0; i 0 ) { From 3661d19dffe5b7db43aa46dc63dcb72aeb7d3850 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Sun, 14 Jul 2019 01:22:13 +0800 Subject: [PATCH 3/8] Create ac.json alternative to assetchains.json with ac_name as unique key --- src/ac.json | 340 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 src/ac.json diff --git a/src/ac.json b/src/ac.json new file mode 100644 index 000000000..5d0052730 --- /dev/null +++ b/src/ac.json @@ -0,0 +1,340 @@ +[{ + "REVS": { + "ac_supply": "1300000" + } + }, + { + "SUPERNET": { + "ac_supply": "816061" + } + }, + { + "DEX": { + "ac_supply": "999999" + } + }, + { + "PANGEA": { + "ac_supply": "999999" + } + }, + { + "JUMBLR": { + "ac_supply": "999999" + } + }, + { + "BET": { + "ac_supply": "999999" + } + }, + { + "CRYPTO": { + "ac_supply": "999999" + } + }, + { + "HODL": { + "ac_supply": "9999999" + } + }, + { + "MSHARK": { + "ac_supply": "1400000" + } + }, + { + "BOTS": { + "ac_supply": "999999" + } + }, + { + "MGW": { + "ac_supply": "999999" + } + }, + { + "COQUI": { + "ac_supply": "72000000", + "ac_ccactivate": "200000" + } + }, + { + "WLC": { + "ac_supply": "210000000" + } + }, + { + "KV": { + "ac_supply": "1000000" + } + }, + { + "CEAL": { + "ac_supply": "366666666" + } + }, + { + "MESH": { + "ac_supply": "1000007" + } + }, + { + "AXO": { + "ac_supply": "200000000", + "ac_ccactivate": "130000" + } + }, + { + "ETOMIC": { + "ac_supply": "100000000" + } + }, + { + "BTCH": { + "ac_supply": "20998641" + } + }, + { + "PIZZA": { + "ac_supply": "100000000" + } + }, + { + "BEER": { + "ac_supply": "100000000" + } + }, + { + "NINJA": { + "ac_supply": "100000000" + } + }, + { + "OOT": { + "ac_supply": "216000000", + "ac_sapling": "5000000" + } + }, + { + "BNTN": { + "ac_supply": "500000000" + } + }, + { + "CHAIN": { + "ac_supply": "999999" + } + }, + { + "PRLPAY": { + "ac_supply": "500000000" + } + }, + { + "DSEC": { + "ac_supply": "7000000" + } + }, + { + "GLXT": { + "ac_supply": "10000000000" + } + }, + { + "EQL": { + "ac_supply": "500000000", + "ac_ccactivate": "205000" + } + }, + { + "ZILLA": { + "ac_supply": "11000000", + "ac_sapling": "5000000", + "addnode": [ + "51.68.215.104" + ] + } + }, + { + "RFOX": { + "ac_supply": "1000000000", + "ac_reward": "100000000" + } + }, + { + "SEC": { + "ac_supply": "1000000000", + "ac_cc": "333" + } + }, + { + "CCL": { + "ac_supply": "200000000", + "ac_end": "1", + "ac_cc": "2", + "addressindex": "1", + "spentindex": "1", + "addnode": [ + "142.93.136.89", + "195.201.22.89" + ] + } + }, + { + "PIRATE": { + "ac_supply": "0", + "ac_reward": "25600000000", + "ac_halving": "77777", + "ac_private": "1", + "addnode": [ + "136.243.102.225" + ] + } + }, + { + "PGT": { + "ac_supply": "10000000", + "ac_end": "1", + "addnode": [ + "190.114.254.104" + ] + } + }, + { + "DION": { + "ac_supply": "3900000000", + "ac_reward": "22260000000", + "ac_staked": "100", + "ac_cc": "1", + "ac_end": "4300000000", + "addnode": [ + "51.75.124.34" + ] + } + }, + { + "KMDICE": { + "ac_supply": "10500000", + "ac_reward": "2500000000", + "ac_halving": "210000", + "ac_cc": "2", + "addressindex": "1", + "spentindex": "1", + "addnode": [ + "144.76.217.232" + ] + } + }, + { + "KSB": { + "ac_supply": "1000000000", + "ac_end": "1", + "ac_public": "1", + "addnode": [ + "37.187.225.231" + ] + } + }, + { + "OUR": { + "ac_reward": "1478310502", + "ac_halving": "525600", + "ac_cc": "42", + "ac_supply": "100000000", + "ac_perc": "77700", + "ac_staked": "93", + "ac_pubkey": "02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c", + "ac_public": "1", + "addnode": [ + "51.255.195.65", + "217.182.129.38", + "37.187.225.231" + ] + } + }, + { + "ILN": { + "ac_supply": "10000000000", + "ac_cc": "2", + "addnode": ["51.75.122.83"] + } + }, + { + "RICK": { + "ac_supply": "90000000000", + "ac_reward": "100000000", + "ac_cc": "3", + "addnode": ["138.201.136.145"] + } + }, + { + "MORTY": { + "ac_supply": "90000000000", + "ac_reward": "100000000", + "ac_cc": "3", + "addnode": ["138.201.136.145"] + } + }, + { + "VOTE2019": { + "ac_supply": "123651638", + "ac_public": "1", + "addnode": ["95.213.238.98"] + } + }, + { + "KOIN": { + "ac_supply": "125000000", + "addnode": ["3.0.32.10"] + } + }, + { + "ZEXO": { + "ac_reward": "1478310502", + "ac_halving": "525600", + "ac_cc": "42", + "ac_ccenable": "236", + "ac_supply": "100000000", + "ac_perc": "77700", + "ac_staked": "93", + "ac_pubkey": "02713bd85e054db923694b6b7a85306264edf4d6bd6d331814f2b40af444b3ebbc", + "ac_public": "1", + "addnode": [ + "195.201.20.230", + "80.240.17.222" + ] + } + }, + { + "K64": { + "ac_reward": "0", + "ac_supply": "64000777", + "ac_staked": "10", + "addnode": ["18.197.20.21"] + } + }, + { + "HUSH3": { + "ac_sapling": "1", + "ac_founders": "1", + "ac_reward": "0,1125000000,562500000", + "ac_end": "128,340000,5422111", + "ac_blocktime": "150", + "ac_supply": "6178674", + "ac_halving": "129,340000,840000", + "ac_cc": "2", + "ac_cclib": "hush3", + "ac_ccenable": "228,234,235,236,241", + "ac_perc": "11111111", + "ac_eras": "3", + "ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac", + "clientname": "GoldenSandtrout", + "addnode": [ + "188.165.212.101", + "136.243.227.142", + "5.9.224.250" + ] + } + } +] From 2ed03590afec86ac57b278a9bc9604a37ce8ca7f Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Sun, 14 Jul 2019 01:25:17 +0800 Subject: [PATCH 4/8] Update ac.json removed outer array --- src/ac.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ac.json b/src/ac.json index 5d0052730..d57dbb8b7 100644 --- a/src/ac.json +++ b/src/ac.json @@ -1,4 +1,4 @@ -[{ +{ "REVS": { "ac_supply": "1300000" } @@ -337,4 +337,3 @@ ] } } -] From 8a20e3a9e7e790f92e0f626fc1dd1ac65f7d3cec Mon Sep 17 00:00:00 2001 From: Dwy ! Date: Sat, 13 Jul 2019 20:15:38 +0200 Subject: [PATCH 5/8] fixed ac.json --- src/ac.json | 186 ++++++++++++++++++++++++++-------------------------- 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/src/ac.json b/src/ac.json index d57dbb8b7..4f75d2f8c 100644 --- a/src/ac.json +++ b/src/ac.json @@ -2,152 +2,152 @@ "REVS": { "ac_supply": "1300000" } - }, - { + , + "SUPERNET": { "ac_supply": "816061" } - }, - { + , + "DEX": { "ac_supply": "999999" } - }, - { + , + "PANGEA": { "ac_supply": "999999" } - }, - { + + , "JUMBLR": { "ac_supply": "999999" } - }, - { + , + "BET": { "ac_supply": "999999" } - }, - { + , + "CRYPTO": { "ac_supply": "999999" } - }, - { + , + "HODL": { "ac_supply": "9999999" } - }, - { + , + "MSHARK": { "ac_supply": "1400000" } - }, - { + , + "BOTS": { "ac_supply": "999999" } - }, - { + , + "MGW": { "ac_supply": "999999" } - }, - { + , + "COQUI": { "ac_supply": "72000000", "ac_ccactivate": "200000" } - }, - { + , + "WLC": { "ac_supply": "210000000" } - }, - { + , + "KV": { "ac_supply": "1000000" } - }, - { + , + "CEAL": { "ac_supply": "366666666" } - }, - { + , + "MESH": { "ac_supply": "1000007" } - }, - { + , + "AXO": { "ac_supply": "200000000", "ac_ccactivate": "130000" } - }, - { + , + "ETOMIC": { "ac_supply": "100000000" } - }, - { + , + "BTCH": { "ac_supply": "20998641" } - }, - { + , + "PIZZA": { "ac_supply": "100000000" } - }, - { + , + "BEER": { "ac_supply": "100000000" } - }, - { + , + "NINJA": { "ac_supply": "100000000" } - }, - { + , + "OOT": { "ac_supply": "216000000", "ac_sapling": "5000000" } - }, - { + , + "BNTN": { "ac_supply": "500000000" } - }, - { + , + "CHAIN": { "ac_supply": "999999" } - }, - { + , + "PRLPAY": { "ac_supply": "500000000" } - }, - { + , + "DSEC": { "ac_supply": "7000000" } - }, - { + , + "GLXT": { "ac_supply": "10000000000" } - }, - { + , + "EQL": { "ac_supply": "500000000", "ac_ccactivate": "205000" } - }, - { + , + "ZILLA": { "ac_supply": "11000000", "ac_sapling": "5000000", @@ -155,20 +155,20 @@ "51.68.215.104" ] } - }, - { + , + "RFOX": { "ac_supply": "1000000000", "ac_reward": "100000000" } - }, - { + , + "SEC": { "ac_supply": "1000000000", "ac_cc": "333" } - }, - { + , + "CCL": { "ac_supply": "200000000", "ac_end": "1", @@ -180,8 +180,8 @@ "195.201.22.89" ] } - }, - { + , + "PIRATE": { "ac_supply": "0", "ac_reward": "25600000000", @@ -191,8 +191,8 @@ "136.243.102.225" ] } - }, - { + , + "PGT": { "ac_supply": "10000000", "ac_end": "1", @@ -200,8 +200,8 @@ "190.114.254.104" ] } - }, - { + , + "DION": { "ac_supply": "3900000000", "ac_reward": "22260000000", @@ -212,8 +212,8 @@ "51.75.124.34" ] } - }, - { + , + "KMDICE": { "ac_supply": "10500000", "ac_reward": "2500000000", @@ -225,8 +225,8 @@ "144.76.217.232" ] } - }, - { + , + "KSB": { "ac_supply": "1000000000", "ac_end": "1", @@ -235,8 +235,8 @@ "37.187.225.231" ] } - }, - { + , + "OUR": { "ac_reward": "1478310502", "ac_halving": "525600", @@ -252,44 +252,44 @@ "37.187.225.231" ] } - }, - { + , + "ILN": { "ac_supply": "10000000000", "ac_cc": "2", "addnode": ["51.75.122.83"] } - }, - { + , + "RICK": { "ac_supply": "90000000000", "ac_reward": "100000000", "ac_cc": "3", "addnode": ["138.201.136.145"] } - }, - { + , + "MORTY": { "ac_supply": "90000000000", "ac_reward": "100000000", "ac_cc": "3", "addnode": ["138.201.136.145"] } - }, - { + , + "VOTE2019": { "ac_supply": "123651638", "ac_public": "1", "addnode": ["95.213.238.98"] } - }, - { + , + "KOIN": { "ac_supply": "125000000", "addnode": ["3.0.32.10"] } - }, - { + , + "ZEXO": { "ac_reward": "1478310502", "ac_halving": "525600", @@ -305,16 +305,16 @@ "80.240.17.222" ] } - }, - { + , + "K64": { "ac_reward": "0", "ac_supply": "64000777", "ac_staked": "10", "addnode": ["18.197.20.21"] } - }, - { + , + "HUSH3": { "ac_sapling": "1", "ac_founders": "1", @@ -336,4 +336,4 @@ "5.9.224.250" ] } - } +} \ No newline at end of file From f186490cdcbce945ea5aa6790f2a967786fd32a3 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Sun, 14 Jul 2019 15:36:52 +0800 Subject: [PATCH 6/8] update to COQUICASH, remove VOTE2019 --- src/ac.json | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/ac.json b/src/ac.json index 4f75d2f8c..7f3f7ba03 100644 --- a/src/ac.json +++ b/src/ac.json @@ -53,13 +53,19 @@ "ac_supply": "999999" } , - - "COQUI": { + "COQUICASH": { "ac_supply": "72000000", - "ac_ccactivate": "200000" + "ac_reward": "7200000000", + "ac_staked": "50", + "ac_halving": "420000", + "ac_cc": "2", + "ac_ccenable": "227,235,236,241", + "addnode": [ + "78.47.108.168" + ] } - , - + , + "WLC": { "ac_supply": "210000000" } @@ -277,13 +283,6 @@ } , - "VOTE2019": { - "ac_supply": "123651638", - "ac_public": "1", - "addnode": ["95.213.238.98"] - } - , - "KOIN": { "ac_supply": "125000000", "addnode": ["3.0.32.10"] @@ -336,4 +335,4 @@ "5.9.224.250" ] } -} \ No newline at end of file +} From b1d53487734bc4256f51514fce039af1e80a7484 Mon Sep 17 00:00:00 2001 From: smk762 <35845239+smk762@users.noreply.github.com> Date: Sun, 14 Jul 2019 15:38:31 +0800 Subject: [PATCH 7/8] update to COQUICASH, remove VOTE2019 --- src/assetchains.json | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 20dd04ee2..e68872d6b 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -44,9 +44,16 @@ "ac_supply": "999999" }, { - "ac_name": "COQUI", + "ac_name": "COQUICASH", "ac_supply": "72000000", - "ac_ccactivate": "200000" + "ac_reward": "7200000000", + "ac_staked": "50", + "ac_halving": "420000", + "ac_cc": "2", + "ac_ccenable": "227,235,236,241", + "addnode": [ + "78.47.108.168" + ] }, { "ac_name": "WLC", @@ -235,12 +242,6 @@ "ac_cc": "3", "addnode": ["138.201.136.145"] }, - { - "ac_name": "VOTE2019", - "ac_supply": "123651638", - "ac_public": "1", - "addnode": ["95.213.238.98"] - }, { "ac_name": "KOIN", "ac_supply": "125000000", From 2b799143f822ca302ba289b4c6b1c891d98b9b10 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Wed, 17 Jul 2019 20:33:51 +0300 Subject: [PATCH 8/8] createrawtransaction enchancement - allowing create OP_RETURN vouts (field "data" in "outputs" json) - allowing using script (hex), in "outputs" (for example, you can use any P2PK, P2PKH or P2SH script as destination) - advanced duplicates checking (users can't use same destination in various forms, for example, you can't make one vout as address and second vout, same address, but coded with P2PK script) - allowing to bypass duplicates check for notaries (for example, to manually create splitfunds txes, using daemon RPC only), for common users it's forbidden Useful usage: Don't forget that you can create raw transaction with empty vins, like createrawtransaction "[]" "{\"RKZWgNw9rvMJCHeD6mFgFNrJGxCoT2bft1\":0.777}" and then fund it (with vins) using fundrawtransaction. Duplicates testing vectors (passed): createrawtransaction "[]" "{\"RKZWgNw9rvMJCHeD6mFgFNrJGxCoT2bft1\":0.777,\"2102c42516ab9b0958f349783222c8b665314ce0f12ae513af1c15e10e8045b87544ac\":0.01}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"2102c42516ab9b0958f349783222c8b665314ce0f12ae513af1c15e10e8045b87544ac\":0.01}" createrawtransaction "[]" "{\"2102c42516ab9b0958f349783222c8b665314ce0f12ae513af1c15e10e8045b87544ac\":0.777,\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.01}" createrawtransaction "[]" "{\"data\":\"010203\",\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.01}" createrawtransaction "[]" "{\"RKZWgNw9rvMJCHeD6mFgFNrJGxCoT2bft1\":0.777,\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.01}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"RKZWgNw9rvMJCHeD6mFgFNrJGxCoT2bft1\":0.01}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"a914fe6ac2ca169440909ab86e2e015db0938b92634787\":0.01}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"a914fe6ac2ca169440909ab86e2e015db0938b92634787\":0.01,\"a914fe6ac2ca169440909ab86e2e015db0938b92634787\":0.02}" createrawtransaction "[]" "{\"76a91470c770cd22061696c01011a020892d136caba70588ac\":0.777,\"a914fe6ac2ca169440909ab86e2e015db0938b92634787\":0.01,\"data\":\"00010203\"}" --- src/rpc/rawtransaction.cpp | 91 +++++++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 7d490dff2..3895375df 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -727,27 +727,31 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp) UniValue createrawtransaction(const UniValue& params, bool fHelp) { + string examplescriptPubKey = "21021ce1eac70455c3e6c52d67c133549b8aed4a588fba594372e8048e65c4f0fcb6ac"; + if (fHelp || params.size() < 2 || params.size() > 4) throw runtime_error( "createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...} ( locktime ) ( expiryheight )\n" - "\nCreate a transaction spending the given inputs and sending to the given addresses.\n" + "\nCreate a transaction spending the given inputs and creating new outputs.\n" + "Outputs can be addresses or standart scripts (in hex) or data.\n" "Returns hex-encoded raw transaction.\n" "Note that the transaction's inputs are not signed, and\n" "it is not stored in the wallet or transmitted to the network.\n" "\nArguments:\n" - "1. \"transactions\" (string, required) A json array of json objects\n" + "1. \"inputs\" (array, required) A json array of json objects\n" " [\n" " {\n" " \"txid\":\"id\", (string, required) The transaction id\n" - " \"vout\":n (numeric, required) The output number\n" - " \"sequence\":n (numeric, optional) The sequence number\n" - " }\n" + " \"vout\":n, (numeric, required) The output number\n" + " \"sequence\":n (numeric, optional) The sequence number\n" + " } \n" " ,...\n" " ]\n" - "2. \"addresses\" (string, required) a json object with addresses as keys and amounts as values\n" + "2. \"outputs\" (object, required) a json object with outputs\n" " {\n" - " \"address\": x.xxx (numeric, required) The key is the Komodo address, the value is the " + CURRENCY_UNIT + " amount\n" + " \"address\": x.xxx, (numeric or string, required) The key is the komodo address or script (in hex), the numeric value (can be string) is the " + CURRENCY_UNIT + " amount\n" + " \"data\": \"hex\" (string, required) The key is \"data\", the value is hex encoded data\n" " ,...\n" " }\n" "3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n" @@ -757,7 +761,11 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) "\nExamples\n" + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"{\\\"address\\\":0.01}\"") - + HelpExampleRpc("createrawtransaction", "[{\"txid\":\"myid\",\"vout\":0}], {\"address\":0.01}") + + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"{\\\""+examplescriptPubKey+"\\\":0.01}\"") + + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"{\\\"data\\\":\\\"00010203\\\"}\"") + + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"") + + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\""+examplescriptPubKey+"\\\":0.01}\"") + + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"data\\\":\\\"00010203\\\"}\"") ); LOCK(cs_main); @@ -817,22 +825,61 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) } std::set destinations; + //std::set destinations; + vector addrList = sendTo.getKeys(); - for (const std::string& name_ : addrList) { - CTxDestination destination = DecodeDestination(name_); - if (!IsValidDestination(destination)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Komodo address: ") + name_); + + if (addrList.size() != sendTo.size()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid outputs")); // for checking edge case, should never happened ... + } + + //for (const std::string& name_ : addrList) { + for (size_t idx = 0; idx < sendTo.size(); idx++) { + + const std::string& name_ = addrList[idx]; + + CScript scriptPubKey; + CTxDestination destination; + + if (name_ == "data") { + std::vector data = ParseHexV(sendTo[name_].getValStr(),"Data"); + CTxOut out(0, CScript() << OP_RETURN << data); + rawTx.vout.push_back(out); + } else { + destination = DecodeDestination(name_); + if (IsValidDestination(destination)) { + scriptPubKey = GetScriptForDestination(destination); + } else if (IsHex(name_)) { + std::vector data(ParseHex(name_)); + scriptPubKey = CScript(data.begin(), data.end()); + // destination is not valid, but we should convert it to valid anyway, to be able to check duplicates, + // so we need to get destination from existing scriptPubKey via ExtractDestination + if (!(ExtractDestination(scriptPubKey, destination) && + (scriptPubKey.IsPayToPublicKeyHash() || scriptPubKey.IsPayToPublicKey() || scriptPubKey.IsPayToScriptHash()) + )) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid script: ") + name_ + std::string(" (only P2PKH, P2PK and P2SH scripts are allowed)")); + } + } + else { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Komodo address or script: ") + name_); + } + + if (!(fExperimentalMode && IS_KOMODO_NOTARY)) { + // support of sending duplicates in createrawtransaction requires experimental features enabled and + // notary flag, to prevent common users to get messed up with duplicates + + //if (!destinations.insert(EncodeDestination(destination)).second) { + if (!destinations.insert(destination).second) { + throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated destination: ") + name_); + } + } + + // CAmount nAmount = AmountFromValue(sendTo[name_]); // operator[](const std::string& key) const; + CAmount nAmount = AmountFromValue(sendTo[idx]); // operator[](size_t index) const; + + CTxOut out(nAmount, scriptPubKey); + rawTx.vout.push_back(out); } - - if (!destinations.insert(destination).second) { - throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_); - } - - CScript scriptPubKey = GetScriptForDestination(destination); - CAmount nAmount = AmountFromValue(sendTo[name_]); - - CTxOut out(nAmount, scriptPubKey); - rawTx.vout.push_back(out); } return EncodeHexTx(rawTx);