mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
pyln-testing: adapt wait_for_onchaind_broadcast function for when onchaind uses lightningd for broadcast.
We can no longer grab the tx in one line as we did with wait_for_onchaind_broadcast, we need to track the broadcast from lightningd. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
86e044a9a8
commit
3e83bed460
@ -1205,6 +1205,26 @@ class LightningNode(object):
|
||||
self.daemon.wait_for_log('peer_out WIRE_UPDATE_FEE')
|
||||
assert(self.rpc.feerates('perkw')['perkw']['opening'] == rate)
|
||||
|
||||
def wait_for_onchaind_tx(self, *args):
|
||||
"""Wait for onchaind to ask lightningd to create one or more txs. Each arg is a pair of typename, resolvename. Returns tuples of the rawtx, txid and number of blocks delay for each pair.
|
||||
"""
|
||||
# Could happen in any order.
|
||||
needle = self.daemon.logsearch_start
|
||||
ret = ()
|
||||
for i in range(0, len(args), 2):
|
||||
self.daemon.logsearch_start = needle
|
||||
r = self.daemon.wait_for_log('Telling lightningd about {} to resolve {}'
|
||||
.format(args[i], args[i + 1]))
|
||||
blocks = int(re.search(r'\(([-0-9]*) more blocks\)', r).group(1))
|
||||
|
||||
# The next 'Broadcast for onchaind' will be the tx.
|
||||
# Now grab the corresponding broadcast lightningd did, to get actual tx:
|
||||
r = self.daemon.wait_for_log('Broadcast for onchaind tx')
|
||||
rawtx = re.search(r'.* tx ([0-9a-fA-F]*)', r).group(1)
|
||||
txid = self.bitcoin.rpc.decoderawtransaction(rawtx, True)['txid']
|
||||
ret = ret + ((rawtx, txid, blocks),)
|
||||
return ret
|
||||
|
||||
def wait_for_onchaind_broadcast(self, name, resolve=None):
|
||||
"""Wait for onchaind to drop tx name to resolve (if any)"""
|
||||
if resolve:
|
||||
|
Loading…
Reference in New Issue
Block a user