mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-17 19:18:00 +02:00
Split signrawtransaction into wallet and non-wallet
Splits signrwatransaction into a wallet version (signrawtransactionwithwallet) and non-wallet version (signrawtransactionwithkey). signrawtransaction is marked as DEPRECATED and will call the right signrawtransaction* command as per the parameters in order to maintain compatibility. Updated signrawtransactions test to use new RPCs
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# Copyright (c) 2015-2017 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test transaction signing using the signrawtransaction RPC."""
|
||||
"""Test transaction signing using the signrawtransactionwithwallet RPC."""
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import *
|
||||
@@ -33,7 +33,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
||||
outputs = {'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB': 0.1}
|
||||
|
||||
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
rawTxSigned = self.nodes[0].signrawtransaction(rawTx, inputs, privKeys)
|
||||
rawTxSigned = self.nodes[0].signrawtransactionwithkey(rawTx, privKeys, inputs)
|
||||
|
||||
# 1) The transaction has a complete set of signatures
|
||||
assert 'complete' in rawTxSigned
|
||||
@@ -84,7 +84,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
||||
# Make sure decoderawtransaction throws if there is extra data
|
||||
assert_raises_rpc_error(-22, "TX decode failed", self.nodes[0].decoderawtransaction, rawTx + "00")
|
||||
|
||||
rawTxSigned = self.nodes[0].signrawtransaction(rawTx, scripts, privKeys)
|
||||
rawTxSigned = self.nodes[0].signrawtransactionwithkey(rawTx, privKeys, scripts)
|
||||
|
||||
# 3) The transaction has no complete set of signatures
|
||||
assert 'complete' in rawTxSigned
|
||||
@@ -112,7 +112,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
||||
# Now test signing failure for transaction with input witnesses
|
||||
p2wpkh_raw_tx = "01000000000102fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000494830450221008b9d1dc26ba6a9cb62127b02742fa9d754cd3bebf337f7a55d114c8e5cdd30be022040529b194ba3f9281a99f2b1c0a19c0489bc22ede944ccf4ecbab4cc618ef3ed01eeffffffef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a0100000000ffffffff02202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac9093510d000000001976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac000247304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee0121025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee635711000000"
|
||||
|
||||
rawTxSigned = self.nodes[0].signrawtransaction(p2wpkh_raw_tx)
|
||||
rawTxSigned = self.nodes[0].signrawtransactionwithwallet(p2wpkh_raw_tx)
|
||||
|
||||
# 7) The transaction has no complete set of signatures
|
||||
assert 'complete' in rawTxSigned
|
||||
|
||||
@@ -472,7 +472,7 @@ def random_transaction(nodes, amount, min_fee, fee_increment, fee_variants):
|
||||
outputs[to_node.getnewaddress()] = float(amount)
|
||||
|
||||
rawtx = from_node.createrawtransaction(inputs, outputs)
|
||||
signresult = from_node.signrawtransaction(rawtx)
|
||||
signresult = from_node.signrawtransactionwithwallet(rawtx)
|
||||
txid = from_node.sendrawtransaction(signresult["hex"], True)
|
||||
|
||||
return (txid, signresult["hex"], fee)
|
||||
@@ -552,7 +552,7 @@ def create_lots_of_big_transactions(node, txouts, utxos, num, fee):
|
||||
newtx = rawtx[0:92]
|
||||
newtx = newtx + txouts
|
||||
newtx = newtx + rawtx[94:]
|
||||
signresult = node.signrawtransaction(newtx, None, None, "NONE")
|
||||
signresult = node.signrawtransactionwithwallet(newtx, None, "NONE")
|
||||
txid = node.sendrawtransaction(signresult["hex"], True)
|
||||
txids.append(txid)
|
||||
return txids
|
||||
|
||||
@@ -78,7 +78,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
|
||||
# Use a different signature hash type to sign. This creates an equivalent but malleated clone.
|
||||
# Don't send the clone anywhere yet
|
||||
tx1_clone = self.nodes[0].signrawtransaction(clone_raw, None, None, "ALL|ANYONECANPAY")
|
||||
tx1_clone = self.nodes[0].signrawtransactionwithwallet(clone_raw, None, "ALL|ANYONECANPAY")
|
||||
assert_equal(tx1_clone["complete"], True)
|
||||
|
||||
# Have node0 mine a block, if requested:
|
||||
|
||||
Reference in New Issue
Block a user