forked from dogecoin/dogecoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet: Avoid leaking locktime fingerprint when anti-fee-sniping
Cherry-picked from: fa48baf Conflicts: - Missing chain().lock(), moved assignment until after locking cs_main. - Different structure and version of test framework required: - Different block heights - Different way of documenting test steps - Removal of wallet check, our tests don't run without a wallet
- Loading branch information
1 parent
a6ac45c
commit cd04448
Showing
3 changed files
with
95 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2018 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
from test_framework.test_framework import BitcoinTestFramework | ||
from test_framework.util import ( | ||
assert_equal, | ||
) | ||
|
||
|
||
class CreateTxWalletTest(BitcoinTestFramework): | ||
def set_test_params(self): | ||
self.setup_clean_chain = False | ||
self.num_nodes = 1 | ||
|
||
def run_test(self): | ||
# Check that we have some (old) blocks and that anti-fee-sniping is disabled | ||
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 120) | ||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) | ||
tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex']) | ||
assert_equal(tx['locktime'], 0) | ||
|
||
# Check that anti-fee-sniping is enabled when we mine a recent block | ||
self.nodes[0].generate(1) | ||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) | ||
tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex']) | ||
assert 0 < tx['locktime'] <= 121 | ||
|
||
|
||
if __name__ == '__main__': | ||
CreateTxWalletTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters