MCPcopy Create free account
hub / github.com/ElementsProject/elements / test_send

Method test_send

test/functional/wallet_send.py:40–180  ·  view source on GitHub ↗
(self, from_wallet, to_wallet=None, amount=None, data=None,
                  arg_conf_target=None, arg_estimate_mode=None, arg_fee_rate=None,
                  conf_target=None, estimate_mode=None, fee_rate=None, add_to_wallet=None, psbt=None,
                  inputs=None, add_inputs=None, include_unsafe=None, change_address=None, change_position=None, change_type=None,
                  include_watching=None, locktime=None, lock_unspents=None, replaceable=None, subtract_fee_from_outputs=None,
                  expect_error=None, solving_data=None)

Source from the content-addressed store, hash-verified

38 self.skip_if_no_wallet()
39
40 def test_send(self, from_wallet, to_wallet=None, amount=None, data=None,
41 arg_conf_target=None, arg_estimate_mode=None, arg_fee_rate=None,
42 conf_target=None, estimate_mode=None, fee_rate=None, add_to_wallet=None, psbt=None,
43 inputs=None, add_inputs=None, include_unsafe=None, change_address=None, change_position=None, change_type=None,
44 include_watching=None, locktime=None, lock_unspents=None, replaceable=None, subtract_fee_from_outputs=None,
45 expect_error=None, solving_data=None):
46 assert (amount is None) != (data is None)
47
48 from_balance_before = from_wallet.getbalances()["mine"]["trusted"]['bitcoin']
49 if include_unsafe:
50 from_balance_before += from_wallet.getbalances()["mine"]["untrusted_pending"]['bitcoin']
51
52 if to_wallet is None:
53 assert amount is None
54 else:
55 to_untrusted_pending_before = to_wallet.getbalances()["mine"]["untrusted_pending"]['bitcoin']
56
57 if amount:
58 dest = to_wallet.getnewaddress()
59 outputs = [{dest: amount}]
60 else:
61 outputs = [{"data": data}]
62
63 # Construct options dictionary
64 options = {}
65 if add_to_wallet is not None:
66 options["add_to_wallet"] = add_to_wallet
67 else:
68 if psbt:
69 add_to_wallet = False
70 else:
71 add_to_wallet = from_wallet.getwalletinfo()["private_keys_enabled"] # Default value
72 if psbt is not None:
73 options["psbt"] = psbt
74 if conf_target is not None:
75 options["conf_target"] = conf_target
76 if estimate_mode is not None:
77 options["estimate_mode"] = estimate_mode
78 if fee_rate is not None:
79 options["fee_rate"] = fee_rate
80 if inputs is not None:
81 options["inputs"] = inputs
82 if add_inputs is not None:
83 options["add_inputs"] = add_inputs
84 if include_unsafe is not None:
85 options["include_unsafe"] = include_unsafe
86 if change_address is not None:
87 options["change_address"] = change_address
88 if change_position is not None:
89 options["change_position"] = change_position
90 if change_type is not None:
91 options["change_type"] = change_type
92 if include_watching is not None:
93 options["include_watching"] = include_watching
94 if locktime is not None:
95 options["locktime"] = locktime
96 if lock_unspents is not None:
97 options["lock_unspents"] = lock_unspents

Callers 1

run_testMethod · 0.95

Calls 4

assert_raises_rpc_errorFunction · 0.90
assert_equalFunction · 0.90
assert_greater_thanFunction · 0.90
sync_mempoolsMethod · 0.80

Tested by

no test coverage detected