Skip to content

Commit 15f4186

Browse files
committed
Add fundrawtransaction RPC call
1 parent 4a05768 commit 15f4186

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

bitcoin/rpc.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,28 @@ def dumpprivkey(self, addr):
296296

297297
return CBitcoinSecret(r)
298298

299+
def fundrawtransaction(self, tx, include_watching=False):
300+
"""Add inputs to a transaction until it has enough in value to meet its out value.
301+
302+
include_watching - Also select inputs which are watch only
303+
304+
Returns dict:
305+
306+
{'tx': Resulting tx,
307+
'fee': Fee the resulting transaction pays,
308+
'changepos': Position of added change output, or -1,
309+
}
310+
"""
311+
hextx = hexlify(tx.serialize())
312+
r = self._call('fundrawtransaction', hextx, include_watching)
313+
314+
r['tx'] = CTransaction.deserialize(unhexlify(r['hex']))
315+
del r['hex']
316+
317+
r['fee'] = int(r['fee'] * COIN)
318+
319+
return r
320+
299321
def getaccountaddress(self, account=None):
300322
"""Return the current Bitcoin address for receiving payments to this
301323
account."""

0 commit comments

Comments
 (0)