20 print(
"Initializing test directory "+self.options.tmpdir)
26 self.
nodes.append(
start_node(0, self.options.tmpdir, [
"-debug",
"-relaypriority=0"]))
27 self.
nodes.append(
start_node(1, self.options.tmpdir, [
"-debug",
"-addressindex"]))
29 self.
nodes.append(
start_node(2, self.options.tmpdir, [
"-debug",
"-addressindex",
"-relaypriority=0"]))
30 self.
nodes.append(
start_node(3, self.options.tmpdir, [
"-debug",
"-addressindex"]))
39 print "Mining blocks..." 53 print "Testing p2pkh and p2sh address index..." 88 print "Testing querying txids by range of block heights.." 90 "addresses": [
"93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB"],
99 multitxids = self.
nodes[1].
getaddresstxids({
"addresses": [
"93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB",
"yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4"]})
113 print "Testing for txid uniqueness..." 114 addressHash =
"FE30B718DCF0BF8A2A686BF1820C073F8B2C3B37".decode(
"hex")
115 scriptPubKey =
CScript([OP_HASH160, addressHash, OP_EQUAL])
118 tx.vin = [
CTxIn(
COutPoint(int(unspent[0][
"txid"], 16), unspent[0][
"vout"]))]
119 tx.vout = [
CTxOut(10, scriptPubKey),
CTxOut(11, scriptPubKey)]
133 print "Testing balances..." 138 print "Testing balances after spending..." 139 privkey2 =
"cU4zhap7nPJAWeMFu4j6jLrfPmqakDAzy8zn8Fhb3oEevdm4e5Lc" 140 address2 =
"yeMpGzMj3rhtnz48XsfpB8itPHhHtgxLc3" 141 addressHash2 =
"C5E4FB9171C22409809A3E8047A29C83886E325D".decode(
"hex")
142 scriptPubKey2 =
CScript([OP_DUP, OP_HASH160, addressHash2, OP_EQUALVERIFY, OP_CHECKSIG])
147 tx.vin = [
CTxIn(
COutPoint(int(unspent[0][
"txid"], 16), unspent[0][
"vout"]))]
148 amount = unspent[0][
"amount"] * 100000000
149 tx.vout = [
CTxOut(amount, scriptPubKey2)]
160 send_amount = 1 * 100000000 + 12840
161 change_amount = amount - send_amount - 10000
162 tx.vout = [
CTxOut(change_amount, scriptPubKey2),
CTxOut(send_amount, scriptPubKey)]
177 balance3 += delta[
"satoshis"]
191 print "Testing utxos..." 197 print "Testing reorg..." 231 print "Testing mempool indexing..." 233 privKey3 =
"cRyrMvvqi1dmpiCmjmmATqjAwo6Wu7QTjKu1ABMYW5aFG4VXW99K" 234 address3 =
"yWB15aAdpeKuSaQHFVJpBDPbNSLZJSnDLA" 235 addressHash3 =
"6C186B3A308A77C779A9BB71C3B5A7EC28232A13".decode(
"hex")
236 scriptPubKey3 =
CScript([OP_DUP, OP_HASH160, addressHash3, OP_EQUALVERIFY, OP_CHECKSIG])
238 scriptPubKey4 =
CScript([OP_HASH160, addressHash3, OP_EQUAL])
242 tx.vin = [
CTxIn(
COutPoint(int(unspent[0][
"txid"], 16), unspent[0][
"vout"]))]
243 amount = unspent[0][
"amount"] * 100000000
244 tx.vout = [
CTxOut(amount, scriptPubKey3)]
251 tx2.vin = [
CTxIn(
COutPoint(int(unspent[1][
"txid"], 16), unspent[1][
"vout"]))]
252 amount = unspent[1][
"amount"] * 100000000
254 CTxOut(amount / 4, scriptPubKey3),
255 CTxOut(amount / 4, scriptPubKey3),
256 CTxOut(amount / 4, scriptPubKey4),
257 CTxOut(amount / 4, scriptPubKey4)
284 tx.vout = [
CTxOut(amount / 2 - 10000, scriptPubKey2)]
299 privkey1 =
"cMvZn1pVWntTEcsK36ZteGQXRAcZ8CoTbMXF1QasxBLdnTwyVQCc" 300 address1 =
"yM9Eed1bxjy7tYxD3yZDHxjcVT48WdRoB1" 301 address1hash =
"0909C84A817651502E020AAD0FBCAE5F656E7D8A".decode(
"hex")
302 address1script =
CScript([OP_DUP, OP_HASH160, address1hash, OP_EQUALVERIFY, OP_CHECKSIG])
313 CTxIn(
COutPoint(int(utxos[0][
"txid"], 16), utxos[0][
"outputIndex"]))
315 amount = utxos[0][
"satoshis"] - 10000
316 tx.vout = [
CTxOut(amount, address1script)]
329 if __name__ ==
'__main__':
UniValue importprivkey(const UniValue ¶ms, bool fHelp)
UniValue getaddressbalance(const UniValue ¶ms, bool fHelp)
UniValue getaddresstxids(const UniValue ¶ms, bool fHelp)
UniValue getaddressdeltas(const UniValue ¶ms, bool fHelp)
UniValue getbalance(const UniValue ¶ms, bool fHelp)
UniValue listunspent(const UniValue ¶ms, bool fHelp)
UniValue sendtoaddress(const UniValue ¶ms, bool fHelp)
UniValue getaddressutxos(const UniValue ¶ms, bool fHelp)
def connect_nodes(from_connection, node_num)
UniValue getblockcount(const UniValue ¶ms, bool fHelp)
def initialize_chain_clean(test_dir, num_nodes)
UniValue signrawtransaction(const UniValue ¶ms, bool fHelp)
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None)
UniValue generate(const UniValue ¶ms, bool fHelp)
UniValue sendrawtransaction(const UniValue ¶ms, bool fHelp)
UniValue getaddressmempool(const UniValue ¶ms, bool fHelp)
UniValue getbestblockhash(const UniValue ¶ms, bool fHelp)
def assert_equal(thing1, thing2)