qa: introduce a sign_and_broadcast utility
This commit is contained in:
parent
d362885b85
commit
3b5cbd5122
@ -75,6 +75,14 @@ def spend_coins(lianad, bitcoind, coins):
|
||||
return tx
|
||||
|
||||
|
||||
def sign_and_broadcast(lianad, bitcoind, psbt, recovery=False):
|
||||
"""Sign a PSBT, finalize it, extract the transaction and broadcast it."""
|
||||
signed_psbt = lianad.sign_psbt(psbt, recovery)
|
||||
finalized_psbt = lianad.finalize_psbt(signed_psbt)
|
||||
tx = finalized_psbt.tx.serialize_with_witness().hex()
|
||||
return bitcoind.rpc.sendrawtransaction(tx)
|
||||
|
||||
|
||||
class RpcError(ValueError):
|
||||
def __init__(self, method: str, params: dict, error: str):
|
||||
super(ValueError, self).__init__(
|
||||
|
||||
@ -8,7 +8,14 @@ from test_framework.serializations import (
|
||||
PSBT_IN_PARTIAL_SIG,
|
||||
PSBT_IN_NON_WITNESS_UTXO,
|
||||
)
|
||||
from test_framework.utils import wait_for, COIN, RpcError, get_txid, spend_coins
|
||||
from test_framework.utils import (
|
||||
wait_for,
|
||||
COIN,
|
||||
RpcError,
|
||||
get_txid,
|
||||
spend_coins,
|
||||
sign_and_broadcast,
|
||||
)
|
||||
|
||||
|
||||
def test_getinfo(lianad):
|
||||
@ -123,10 +130,7 @@ def test_create_spend(lianad, bitcoind):
|
||||
)
|
||||
|
||||
# We can sign it and broadcast it.
|
||||
signed_psbt = lianad.sign_psbt(PSBT.from_base64(res["psbt"]))
|
||||
finalized_psbt = lianad.finalize_psbt(signed_psbt)
|
||||
tx = finalized_psbt.tx.serialize_with_witness().hex()
|
||||
bitcoind.rpc.sendrawtransaction(tx)
|
||||
sign_and_broadcast(PSBT.from_base64(res["psbt"]))
|
||||
|
||||
|
||||
def test_list_spend(lianad, bitcoind):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user