-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Add and use satToBtc and btcToSat util functions
#31356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,6 @@ | |
| ) | ||
| from test_framework.messages import ( | ||
| CBlock, | ||
| COIN, | ||
| COutPoint, | ||
| CTransaction, | ||
| CTxIn, | ||
|
|
@@ -24,6 +23,7 @@ | |
| SEQUENCE_FINAL, | ||
| uint256_from_compact, | ||
| uint256_from_str, | ||
| btcToSat, | ||
| ) | ||
| from test_framework.p2p import P2PDataStore | ||
| from test_framework.script import ( | ||
|
|
@@ -809,7 +809,7 @@ def run_test(self): | |
| self.log.info("Reject a block with a transaction with outputs > inputs") | ||
| self.move_tip(57) | ||
| self.next_block(59) | ||
| tx = self.create_and_sign_transaction(out[17], 51 * COIN) | ||
| tx = self.create_and_sign_transaction(out[17], btcToSat(51)) | ||
| b59 = self.update_block(59, [tx]) | ||
| self.send_blocks([b59], success=False, reject_reason='bad-txns-in-belowout', reconnect=True) | ||
|
|
||
|
|
@@ -1159,18 +1159,18 @@ def run_test(self): | |
| self.log.info("Test transaction resurrection during a re-org") | ||
| self.move_tip(76) | ||
| self.next_block(77) | ||
| tx77 = self.create_and_sign_transaction(out[24], 10 * COIN) | ||
| tx77 = self.create_and_sign_transaction(out[24], btcToSat(10)) | ||
|
||
| b77 = self.update_block(77, [tx77]) | ||
| self.send_blocks([b77], True) | ||
| self.save_spendable_output() | ||
|
|
||
| self.next_block(78) | ||
| tx78 = self.create_tx(tx77, 0, 9 * COIN) | ||
| tx78 = self.create_tx(tx77, 0, btcToSat(9)) | ||
| b78 = self.update_block(78, [tx78]) | ||
| self.send_blocks([b78], True) | ||
|
|
||
| self.next_block(79) | ||
| tx79 = self.create_tx(tx78, 0, 8 * COIN) | ||
| tx79 = self.create_tx(tx78, 0, btcToSat(8)) | ||
| b79 = self.update_block(79, [tx79]) | ||
| self.send_blocks([b79], True) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,8 @@ | |
| create_coinbase, | ||
| ) | ||
| from test_framework.messages import ( | ||
| COIN, | ||
| CTxOut, | ||
| btcToSat, | ||
| ) | ||
| from test_framework.script import ( | ||
| CScript, | ||
|
|
@@ -152,7 +152,7 @@ def _test_coin_stats_index(self): | |
| tx1 = self.wallet.send_to( | ||
| from_node=node, | ||
| scriptPubKey=self.wallet.get_scriptPubKey(), | ||
| amount=21 * COIN, | ||
| amount=btcToSat(21), | ||
| ) | ||
|
|
||
| # Find the right position of the 21 BTC output | ||
|
|
@@ -161,7 +161,7 @@ def _test_coin_stats_index(self): | |
| # Generate and send another tx with an OP_RETURN output (which is unspendable) | ||
| tx2 = self.wallet.create_self_transfer(utxo_to_spend=tx1_out_21)['tx'] | ||
| tx2_val = '20.99' | ||
| tx2.vout = [CTxOut(int(Decimal(tx2_val) * COIN), CScript([OP_RETURN] + [OP_FALSE] * 30))] | ||
| tx2.vout = [CTxOut(btcToSat(Decimal(tx2_val)), CScript([OP_RETURN] + [OP_FALSE] * 30))] | ||
|
Comment on lines
163
to
+164
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe accepting a string with internal string to decimal checking and conversion would also make it more flexible? The explicit
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An alternative idea would be to add a |
||
| tx2_hex = tx2.serialize().hex() | ||
| self.nodes[0].sendrawtransaction(tx2_hex, 0, tx2_val) | ||
|
|
||
|
|
@@ -189,7 +189,7 @@ def _test_coin_stats_index(self): | |
| # Create a coinbase that does not claim full subsidy and also | ||
| # has two outputs | ||
| cb = create_coinbase(109, nValue=35) | ||
| cb.vout.append(CTxOut(5 * COIN, CScript([OP_FALSE]))) | ||
| cb.vout.append(CTxOut(btcToSat(5), CScript([OP_FALSE]))) | ||
| cb.rehash() | ||
|
|
||
| # Generate a block that includes previous coinbase | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, a fee rate conversion helper here would make reading this far easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conversion was not intuitive to me in the first glance: #30079 (comment)