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

Function create_confirmed_utxos

test/functional/test_framework/util.py:506–532  ·  view source on GitHub ↗
(test_framework, fee, node, count, **kwargs)

Source from the content-addressed store, hash-verified

504# Helper to create at least "count" utxos
505# Pass in a fee that is sufficient for relay and mining new transactions.
506def create_confirmed_utxos(test_framework, fee, node, count, **kwargs):
507 to_generate = int(0.5 * count) + 101
508 while to_generate > 0:
509 test_framework.generate(node, min(25, to_generate), **kwargs)
510 to_generate -= 25
511 utxos = node.listunspent()
512 iterations = count - len(utxos)
513 addr1 = node.getnewaddress()
514 addr2 = node.getnewaddress()
515 if iterations <= 0:
516 return utxos
517 for _ in range(iterations):
518 t = utxos.pop()
519 inputs = []
520 inputs.append({"txid": t["txid"], "vout": t["vout"]})
521 send_value = t['amount'] - fee
522 outputs = [{addr1: satoshi_round(send_value / 2)}, {addr2: satoshi_round(send_value / 2)}, {"fee": fee}]
523 raw_tx = node.createrawtransaction(inputs, outputs)
524 signed_tx = node.signrawtransactionwithwallet(raw_tx)["hex"]
525 node.sendrawtransaction(signed_tx)
526
527 while (node.getmempoolinfo()['size'] > 0):
528 test_framework.generate(node, 1, **kwargs)
529
530 utxos = node.listunspent()
531 assert len(utxos) >= count
532 return utxos
533
534
535def chain_transaction(node, parent_txids, vouts, value, fee, num_outputs):

Callers 3

run_testMethod · 0.90
run_testMethod · 0.90
test_broadcastMethod · 0.90

Calls 3

sendrawtransactionMethod · 0.80
satoshi_roundFunction · 0.70
generateMethod · 0.45

Tested by 1

test_broadcastMethod · 0.72