| 504 | # Helper to create at least "count" utxos |
| 505 | # Pass in a fee that is sufficient for relay and mining new transactions. |
| 506 | def 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 | |
| 535 | def chain_transaction(node, parent_txids, vouts, value, fee, num_outputs): |