16 parser.add_option(
"--mineblock", dest=
"mine_block", default=
False, action=
"store_true",
17 help=
"Test double-spend of 1-confirmed transaction")
25 starting_balance = 12500
34 fund_foo_txid = self.
nodes[0].
sendfrom(
"", node0_address_foo, 12190)
38 fund_bar_txid = self.
nodes[0].
sendfrom(
"", node0_address_bar, 290)
42 starting_balance - 12190 - 290 + fund_foo_tx[
"fee"] + fund_bar_tx[
"fee"])
53 clone_inputs = [{
"txid":rawtx1[
"vin"][0][
"txid"],
"vout":rawtx1[
"vin"][0][
"vout"]}]
54 clone_outputs = {rawtx1[
"vout"][0][
"scriptPubKey"][
"addresses"][0]:rawtx1[
"vout"][0][
"value"],
55 rawtx1[
"vout"][1][
"scriptPubKey"][
"addresses"][0]:rawtx1[
"vout"][1][
"value"]}
62 seqbe =
'%08x' % rawtx1[
"vin"][0][
"sequence"]
63 clone_raw = clone_raw[:posseq] + seqbe[6:8] + seqbe[4:6] + seqbe[2:4] + seqbe[0:2] + clone_raw[posseq + 8:]
68 pos0 = 2*(4+1+36+1+4+1)
69 hex400 =
"00902f5009000000" 70 output_len = 16 + 2 + 2 * int(
"0x" + clone_raw[pos0 + 16 : pos0 + 16 + 2], 0)
71 if (rawtx1[
"vout"][0][
"value"] == 400
and clone_raw[pos0 : pos0 + 16] != hex400
or 72 rawtx1[
"vout"][0][
"value"] != 400
and clone_raw[pos0 : pos0 + 16] == hex400):
73 output0 = clone_raw[pos0 : pos0 + output_len]
74 output1 = clone_raw[pos0 + output_len : pos0 + 2 * output_len]
75 clone_raw = clone_raw[:pos0] + output1 + output0 + clone_raw[pos0 + 2 * output_len:]
78 poslt = pos0 + 2 * output_len
79 ltbe =
'%08x' % rawtx1[
"locktime"]
80 clone_raw = clone_raw[:poslt] + ltbe[6:8] + ltbe[4:6] + ltbe[2:4] + ltbe[0:2] + clone_raw[poslt + 8:]
88 if (self.options.mine_block):
97 expected = starting_balance + fund_foo_tx[
"fee"] + fund_bar_tx[
"fee"]
98 if self.options.mine_block: expected += 500
99 expected += tx1[
"amount"] + tx1[
"fee"]
100 expected += tx2[
"amount"] + tx2[
"fee"]
107 if self.options.mine_block:
142 if (self.options.mine_block):
163 if __name__ ==
'__main__':
UniValue settxfee(const UniValue ¶ms, bool fHelp)
UniValue getbalance(const UniValue ¶ms, bool fHelp)
UniValue getrawtransaction(const UniValue ¶ms, bool fHelp)
UniValue sendfrom(const UniValue ¶ms, bool fHelp)
def connect_nodes(from_connection, node_num)
UniValue getnewaddress(const UniValue ¶ms, bool fHelp)
UniValue signrawtransaction(const UniValue ¶ms, bool fHelp)
UniValue createrawtransaction(const UniValue ¶ms, bool fHelp)
UniValue generate(const UniValue ¶ms, bool fHelp)
UniValue sendrawtransaction(const UniValue ¶ms, bool fHelp)
def sync_blocks(rpc_connections, wait=1)
def add_options(self, parser)
def assert_equal(thing1, thing2)
UniValue gettransaction(const UniValue ¶ms, bool fHelp)