Skip to content

Commit 242586c

Browse files
committed
lint: fix pylint issues
1 parent ba8273a commit 242586c

File tree

12 files changed

+57
-56
lines changed

12 files changed

+57
-56
lines changed

contrib/assets_tutorial/assets_tutorial.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
from decimal import Decimal
88

9-
## 0. Boilerplate to make the tutorial executable as a script
9+
# 0. Boilerplate to make the tutorial executable as a script
1010
#
1111
# Skip ahead to step 1 if you are reading
1212
#
@@ -44,7 +44,7 @@
4444
not args.no_cleanup,
4545
)
4646

47-
## 1. Start nodes
47+
# 1. Start nodes
4848
print ("1. Start nodes")
4949
#
5050
# 1a. Confirm that we not start an elements node if validatepegin is set and there
@@ -132,7 +132,7 @@
132132
assert e1.getblockcount() == 10
133133
assert e1.getbestblockhash() == e2.getbestblockhash()
134134

135-
## 2. Basic wallet usage
135+
# 2. Basic wallet usage
136136
print ("")
137137
print ("2. Basic wallet usage")
138138

@@ -225,7 +225,7 @@
225225
else:
226226
raise Exception("Transaction 3 should not be in wallet 1")
227227

228-
## 3. Confidential assets and keys
228+
# 3. Confidential assets and keys
229229
print ("")
230230
print ("3. Confidential Keys")
231231
current_e1_balance = e1.getbalance()
@@ -264,7 +264,7 @@
264264
e1.generatetoaddress(1, e1.getnewaddress())
265265
sync_all([e1, e2])
266266

267-
## 4. 2-of-2 multisig
267+
# 4. 2-of-2 multisig
268268
#
269269
# Let's build a blinded 2-of-2 multisig p2sh address
270270
print ("")
@@ -303,7 +303,7 @@
303303
assert e1.gettransaction(txid, True)['details'] != []
304304
assert e2.gettransaction(txid, True)['details'] != []
305305

306-
## 5. Multi-asset support
306+
# 5. Multi-asset support
307307
#
308308
# Many of the RPC calls have added asset type or label arguments, and reveal
309309
# alternative asset information. With no argument all are listed. For example,
@@ -338,7 +338,6 @@
338338
assert new_issuances[0]['assetamount'] == 1
339339
assert new_issuances[0]['tokenamount'] == 1
340340

341-
assert len(e2.listissuances()) == 1 ## ANDREW
342341
print ("5b. Reissue the asset using the reissuance token.")
343342
# If you gave `issueasset` a reissuance token argument greater than 0
344343
# you can also reissue the base asset. This will appear as a second issuance
@@ -449,7 +448,7 @@
449448
e1.generatetoaddress(1, e1.getnewaddress())
450449
sync_all([e1, e2])
451450

452-
## 6. Blocksigning
451+
# 6. Blocksigning
453452
#
454453
# Up to now, we have been generating blocks to the default OP_TRUE script. Let's
455454
# make this script more interesting. We'll use a 2-of-2 multisig made from keys
@@ -561,7 +560,7 @@
561560
assert e1.getblockcount() == 1
562561
assert e2.getblockcount() == 1
563562

564-
## The peg
563+
# The peg
565564
#
566565
# Everything peg-related can be done inside the Elements daemon directly,
567566
# except for processing pegouts. This is because processing pegouts involves
@@ -665,7 +664,7 @@
665664
e1.sendtomainchain(bitcoin.getnewaddress(), 5)
666665

667666

668-
## Exercise(s)
667+
# Exercise(s)
669668
#
670669
# 1. Implement really dumb/unsafe watchmen to allow pegouts for learning purposes.
671670
# To custody the coins that users peg in, you need to extract the tweak from

contrib/assets_tutorial/pset_swap_tutorial.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
from test_framework.authproxy import JSONRPCException
44
from test_framework.daemon import Daemon, sync_all
55
import argparse
6-
import sys
7-
from decimal import Decimal
86

9-
## PSET Swap Tutorial
7+
# PSET Swap Tutorial
108
#
119
# This script demonstrates how to implement an atomic swap, using a single
1210
# Elements transaction, between two parties, Alice and Carol. Alice has
@@ -18,7 +16,7 @@
1816
# going on.
1917
#
2018

21-
## 0. Boilerplate to make the tutorial executable as a script
19+
# 0. Boilerplate to make the tutorial executable as a script
2220
#
2321
# Skip ahead to step 1 if you are reading
2422
#
@@ -47,7 +45,7 @@
4745
not args.no_cleanup,
4846
)
4947

50-
## 1. Start nodes
48+
# 1. Start nodes
5149
print ("1. Start nodes and setup scenario")
5250

5351
# 1a. Turn on both nodes. Disable -validatepegin as we will just swap the
@@ -92,7 +90,7 @@
9290
assert len(alice.listunspent()) > 0
9391
assert len(carol.listunspent()) > 0
9492

95-
## 2. Construct a swap transaction in PSET format
93+
# 2. Construct a swap transaction in PSET format
9694
#
9795
# At this point node `alice` has 10.5MM "bitcoin" and node `carol` has 1000 of
9896
# a new asset. We want to do an atomic swap: 2500 BTC for 1000 of
@@ -119,7 +117,7 @@
119117
print (" Alice: ", alice_addr)
120118
print (" Carol: ", carol_addr)
121119

122-
# Then they each create and fund (but don't sign!) partial transactions
120+
# Then they each create and fund (but don't sign!) partial transactions
123121
# which simply send the assets to each other.
124122
print ("2b. Exchange partial transaction data")
125123
raw_tx_a = alice.createrawtransaction(outputs=[{carol_addr: 2500}])
@@ -148,12 +146,12 @@
148146
assert feerate > 0.1 # should probably compare against your own feerate
149147
assert found_my_output
150148

151-
##
152-
## Check that none of the inputs in the counterparty's transaction actually
153-
## belong to us. This is the second-most important check (after making sure
154-
## that your outputs are present :)) and by far the easiest to forget. Do
155-
## not forget this!!!
156-
##
149+
#
150+
# Check that none of the inputs in the counterparty's transaction actually
151+
# belong to us. This is the second-most important check (after making sure
152+
# that your outputs are present :)) and by far the easiest to forget. Do
153+
# not forget this!!!
154+
#
157155

158156
# The way we do this check in Python is by making a set of each
159157
# output the wallet can spend...
@@ -235,7 +233,7 @@
235233
assert not any([x["is_final"] for x in analysis["inputs"]])
236234
assert all([x["next"] == "updater" for x in analysis["inputs"]])
237235

238-
## 3. Update the PSET
236+
# 3. Update the PSET
239237
#
240238
# Before blinding can take place, both parties need to provide UTXO data
241239
# for their inputs. They can share this data by either updating the PSET
@@ -258,7 +256,7 @@
258256
assert not any([x["is_final"] for x in analysis["inputs"]])
259257
assert all([x["next"] == "signer" for x in analysis["inputs"]])
260258

261-
## 4. Blind the PSET
259+
# 4. Blind the PSET
262260
#
263261
# Both parties now blind the PSET. Importantly, the final person to blind must
264262
# have a combined PSET that has everyone else's blinding data included, so that
@@ -314,7 +312,7 @@
314312
assert not any([x["is_final"] for x in analysis["inputs"]])
315313
assert all([x["next"] == "signer" for x in analysis["inputs"]])
316314

317-
## 5. Sign the PSET
315+
# 5. Sign the PSET
318316
#
319317
# When signing, there are a couple options for workflows. Each party can sign
320318
# in turn, like we did when blinding, or they can each sign independently and

contrib/assets_tutorial/test_framework/daemon.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
from test_framework.authproxy import AuthServiceProxy
33

4-
import pathlib
54
import tempfile
65
import time
76
import shutil
@@ -41,7 +40,7 @@ def shutdown(self):
4140
if self.proc is not None:
4241
print ("Shutting down %s" % self.name)
4342
self.proc.terminate()
44-
## FIXME determine why we need 30+ seconds to shut down with a tiny regtest chain
43+
# FIXME determine why we need 30+ seconds to shut down with a tiny regtest chain
4544
self.proc.wait(120)
4645
self.proc = None
4746

@@ -92,8 +91,6 @@ def __getitem__(self, key):
9291
return self.config[key]
9392

9493
def sync_all(nodes, timeout_sec = 10):
95-
totalWait = timeout_sec
96-
9794
stop_time = time.time() + timeout_sec
9895
while time.time() <= stop_time:
9996
best_hash = [x.getbestblockhash() for x in nodes]

test/functional/data/invalid_txs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# OP_RIGHT,
5050
# OP_RSHIFT,
5151
# OP_SUBSTR,
52-
OP_TRUE,
52+
# OP_TRUE,
5353
# OP_XOR,
5454
)
5555
from test_framework.script_util import (

test/functional/feature_fedpeg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
COIN,
2121
CBlock,
2222
COutPoint,
23-
CTransaction,
2423
CTxIn,
2524
CTxInWitness,
2625
CTxOut,

test/functional/feature_issuance.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def run_test(self):
482482
self.nodes[0].generate(1)
483483
assert_equal(self.nodes[0].gettransaction(tx_id)["confirmations"], 1)
484484

485-
## Regression for one form of https://github.com/bitcoin/bitcoin/issues/20347
485+
# Regression for one form of https://github.com/bitcoin/bitcoin/issues/20347
486486
# 1. Leave node 1 with only a single small explicit output
487487
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance()['bitcoin'], "", "", True)
488488
blind_addr = self.nodes[1].getnewaddress()
@@ -497,8 +497,7 @@ def run_test(self):
497497
# in the 3-output case. As the bug causes us to do coin selection for
498498
# the former while attempting to produce the latter, we will trigger
499499
# an "impossible" case and a confusing/generic error message.
500-
txid = self.nodes[1].issueasset(0, 1, False)["txid"]
501-
tx = self.nodes[1].getrawtransaction(txid, True)
500+
self.nodes[1].issueasset(0, 1, False)["txid"]
502501

503502
if __name__ == '__main__':
504503
IssuanceTest ().main ()

test/functional/feature_taphash_pegins_issuances.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#
77
# Test for taproot sighash algorithm with pegins and issuances
88

9-
from test_framework.key import ECKey, ECPubKey, compute_xonly_pubkey, generate_privkey, sign_schnorr, tweak_add_privkey, tweak_add_pubkey, verify_schnorr
10-
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, CTxOutValue, CTxOutWitness, tx_from_hex, uint256_from_str
11-
from test_framework.test_framework import BitcoinTestFramework, SkipTest
9+
from test_framework.key import compute_xonly_pubkey, generate_privkey, sign_schnorr, tweak_add_privkey, tweak_add_pubkey, verify_schnorr
10+
from test_framework.messages import COutPoint, CTxIn, CTxInWitness, CTxOut, CTxOutValue, CTxOutWitness, tx_from_hex, uint256_from_str
11+
from test_framework.test_framework import BitcoinTestFramework
1212
from test_framework.script import TaprootSignatureHash, taproot_construct, taproot_pad_sighash_ty, SIGHASH_DEFAULT, SIGHASH_ALL, SIGHASH_NONE, SIGHASH_SINGLE, SIGHASH_ANYONECANPAY
1313

1414
VALID_SIGHASHES_ECDSA = [
@@ -77,7 +77,7 @@ def create_taproot_utxo(self):
7777

7878
tx = self.nodes[0].blindrawtransaction(fund_tx.serialize().hex())
7979
signed_raw_tx = self.nodes[0].signrawtransactionwithwallet(tx)
80-
_txid = self.nodes[0].sendrawtransaction(signed_raw_tx['hex'])
80+
self.nodes[0].sendrawtransaction(signed_raw_tx['hex'])
8181
tx = tx_from_hex(signed_raw_tx['hex'])
8282
tx.rehash()
8383
self.nodes[0].generate(1)

test/functional/feature_tapscript_opcodes.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
from random import randint
1010
from test_framework.util import BITCOIN_ASSET_BYTES, assert_raises_rpc_error, satoshi_round
11-
from test_framework.key import ECKey, ECPubKey, compute_xonly_pubkey, generate_privkey, sign_schnorr, tweak_add_privkey, tweak_add_pubkey, verify_schnorr
12-
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, CTxOutNonce, CTxOutValue, CTxOutWitness, ser_uint256, sha256, tx_from_hex, uint256_from_str
11+
from test_framework.key import ECKey, compute_xonly_pubkey, generate_privkey, sign_schnorr
12+
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, CTxOutNonce, CTxOutValue, ser_uint256, sha256, tx_from_hex
1313
from test_framework.test_framework import BitcoinTestFramework
14-
from test_framework.script import CScript, CScriptNum, CScriptOp, OP_0, OP_1, OP_2, OP_3, OP_4, OP_5, OP_6, OP_7, OP_ADD64, OP_AND, OP_CAT, OP_CHECKSIGFROMSTACK, OP_DIV64, OP_DROP, OP_DUP, OP_ECMULSCALARVERIFY, OP_ELSE, OP_EQUAL, OP_EQUALVERIFY, OP_FALSE, OP_FROMALTSTACK, OP_GREATERTHAN64, OP_GREATERTHANOREQUAL64, OP_INSPECTINPUTASSET, OP_INSPECTINPUTISSUANCE, OP_INSPECTINPUTOUTPOINT, OP_INSPECTINPUTSCRIPTPUBKEY, OP_INSPECTINPUTSEQUENCE, OP_INSPECTINPUTVALUE, OP_INSPECTLOCKTIME, OP_INSPECTNUMINPUTS, OP_INSPECTNUMOUTPUTS, OP_INSPECTOUTPUTASSET, OP_INSPECTOUTPUTNONCE, OP_INSPECTOUTPUTSCRIPTPUBKEY, OP_INSPECTOUTPUTVALUE, OP_IF, OP_INSPECTVERSION, OP_LE32TOLE64, OP_LE64TOSCRIPTNUM, OP_LESSTHAN64, OP_LESSTHANOREQUAL64, OP_MUL64, OP_NEG64, OP_NOT, OP_INVERT, OP_NOTIF, OP_OR, OP_PUSHCURRENTINPUTINDEX, OP_SCRIPTNUMTOLE64, OP_SHA256FINALIZE, OP_SHA256INITIALIZE, OP_SHA256UPDATE, OP_SIZE, OP_SUB64, OP_SWAP, OP_TWEAKVERIFY, OP_TOALTSTACK, OP_TXWEIGHT, OP_VERIFY, OP_XOR, OP_XOR, TaprootSignatureHash, taproot_construct, SIGHASH_DEFAULT, SIGHASH_ALL, SIGHASH_NONE, SIGHASH_SINGLE, SIGHASH_ANYONECANPAY
14+
from test_framework.script import CScript, CScriptNum, CScriptOp, OP_0, OP_1, OP_2, OP_ADD64, OP_AND, OP_CHECKSIGFROMSTACK, OP_DIV64, OP_DROP, OP_DUP, OP_ECMULSCALARVERIFY, OP_EQUAL, OP_EQUALVERIFY, OP_FALSE, OP_FROMALTSTACK, OP_GREATERTHAN64, OP_GREATERTHANOREQUAL64, OP_INSPECTINPUTASSET, OP_INSPECTINPUTISSUANCE, OP_INSPECTINPUTOUTPOINT, OP_INSPECTINPUTSCRIPTPUBKEY, OP_INSPECTINPUTSEQUENCE, OP_INSPECTINPUTVALUE, OP_INSPECTLOCKTIME, OP_INSPECTNUMINPUTS, OP_INSPECTNUMOUTPUTS, OP_INSPECTOUTPUTASSET, OP_INSPECTOUTPUTNONCE, OP_INSPECTOUTPUTSCRIPTPUBKEY, OP_INSPECTOUTPUTVALUE, OP_INSPECTVERSION, OP_LE32TOLE64, OP_LE64TOSCRIPTNUM, OP_LESSTHAN64, OP_LESSTHANOREQUAL64, OP_MUL64, OP_NEG64, OP_NOT, OP_INVERT, OP_OR, OP_PUSHCURRENTINPUTINDEX, OP_SCRIPTNUMTOLE64, OP_SHA256FINALIZE, OP_SHA256INITIALIZE, OP_SHA256UPDATE, OP_SIZE, OP_SUB64, OP_SWAP, OP_TWEAKVERIFY, OP_TOALTSTACK, OP_TXWEIGHT, OP_VERIFY, OP_XOR, taproot_construct, SIGHASH_DEFAULT, SIGHASH_ALL, SIGHASH_NONE, SIGHASH_SINGLE, SIGHASH_ANYONECANPAY
1515

1616
import os
1717

@@ -93,7 +93,7 @@ def create_taproot_utxo(self, scripts = None, blind = False):
9393

9494
tx = self.nodes[0].blindrawtransaction(fund_tx.serialize().hex())
9595
signed_raw_tx = self.nodes[0].signrawtransactionwithwallet(tx)
96-
_txid = self.nodes[0].sendrawtransaction(signed_raw_tx['hex'])
96+
self.nodes[0].sendrawtransaction(signed_raw_tx['hex'])
9797
tx = tx_from_hex(signed_raw_tx['hex'])
9898
tx.rehash()
9999
self.nodes[0].generate(1)
@@ -102,11 +102,13 @@ def create_taproot_utxo(self, scripts = None, blind = False):
102102

103103
return tx, prev_vout, spk, sec, pub, tap
104104

105-
def tapscript_satisfy_test(self, script, inputs = [], add_issuance = False,
106-
add_pegin = False, fail=None, add_prevout=False, add_asset=False,
107-
add_value=False, add_spk = False, seq = 0, add_out_spk = None,
108-
add_out_asset = None, add_out_value = None, add_out_nonce = None,
109-
ver = 2, locktime = 0, add_num_outputs=False, add_weight=False, blind=False):
105+
def tapscript_satisfy_test(self, script, inputs = None, add_issuance = False,
106+
add_pegin = False, fail=None, add_prevout=False, add_asset=False,
107+
add_value=False, add_spk = False, seq = 0, add_out_spk = None,
108+
add_out_asset = None, add_out_value = None, add_out_nonce = None,
109+
ver = 2, locktime = 0, add_num_outputs=False, add_weight=False, blind=False):
110+
if inputs is None:
111+
inputs = []
110112
# Create a taproot utxo
111113
scripts = [("s0", script)]
112114
prev_tx, prev_vout, spk, sec, pub, tap = self.create_taproot_utxo(scripts)
@@ -387,20 +389,28 @@ def le8(x, signed=True):
387389

388390
def check_add(a, b, c, fail=None):
389391
self.tapscript_satisfy_test(CScript([OP_ADD64, OP_VERIFY, le8(c), OP_EQUAL]), inputs = [le8(a), le8(b)], fail=fail)
392+
390393
def check_sub(a, b, c, fail=None):
391394
self.tapscript_satisfy_test(CScript([OP_SUB64, OP_VERIFY, le8(c), OP_EQUAL]), inputs = [le8(a), le8(b)], fail=fail)
395+
392396
def check_mul(a, b, c, fail=None):
393397
self.tapscript_satisfy_test(CScript([OP_MUL64, OP_VERIFY, le8(c), OP_EQUAL]), inputs = [le8(a), le8(b)], fail=fail)
398+
394399
def check_div(a, b, q, r, fail=None):
395400
self.tapscript_satisfy_test(CScript([OP_DIV64, OP_VERIFY, le8(q), OP_EQUALVERIFY, le8(r), OP_EQUAL]), inputs = [le8(a), le8(b)], fail=fail)
401+
396402
def check_le(a, b, res, fail=None):
397403
self.tapscript_satisfy_test(CScript([OP_LESSTHAN64, res, OP_EQUAL]), inputs = [le8(a), le8(b)], fail=fail)
404+
398405
def check_leq(a, b, res, fail=None):
399406
self.tapscript_satisfy_test(CScript([OP_LESSTHANOREQUAL64, res, OP_EQUAL]), inputs = [le8(a), le8(b)], fail=fail)
407+
400408
def check_ge(a, b, res, fail=None):
401409
self.tapscript_satisfy_test(CScript([OP_GREATERTHAN64, res, OP_EQUAL]), inputs = [le8(a), le8(b)], fail=fail)
410+
402411
def check_geq(a, b, res, fail=None):
403412
self.tapscript_satisfy_test(CScript([OP_GREATERTHANOREQUAL64, res, OP_EQUAL]), inputs = [le8(a), le8(b)], fail=fail)
413+
404414
def check_neg(a, res, fail=None):
405415
self.tapscript_satisfy_test(CScript([OP_NEG64, OP_VERIFY, le8(res), OP_EQUAL]), inputs = [le8(a)], fail=fail)
406416
# Arithematic opcodes

test/functional/rpc_invalid_address_message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
INVALID_ADDRESS = 'asfah14i8fajz0123f'
2626

27-
## ELEMENTS
27+
# ELEMENTS
2828
BLECH32_VALID = 'el1qq0umk3pez693jrrlxz9ndlkuwne93gdu9g83mhhzuyf46e3mdzfpva0w48gqgzgrklncnm0k5zeyw8my2ypfsmxh4xcjh2rse'
2929
BLECH32_INVALID_BLECH32 = 'el1pq0umk3pez693jrrlxz9ndlkuwne93gdu9g83mhhzuyf46e3mdzfpva0w48gqgzgrklncnm0k5zeyw8my2ypfsxguu9nrdg2pc'
3030
BLECH32_INVALID_BLECH32M = 'el1qq0umk3pez693jrrlxz9ndlkuwne93gdu9g83mhhzuyf46e3mdzfpva0w48gqgzgrklncnm0k5zeyw8my2ypfsnnmzrstzt7de'
@@ -84,7 +84,7 @@ def test_validateaddress(self):
8484
assert not info['isvalid']
8585
assert_equal(info['error'], 'Invalid address format')
8686

87-
## ELEMENTS
87+
# ELEMENTS
8888
info = node.validateaddress(BLECH32_INVALID_SIZE)
8989
assert not info['isvalid']
9090
assert_equal(info['error'], 'Invalid Blech32 address data size')
@@ -116,7 +116,7 @@ def test_getaddressinfo(self):
116116

117117
assert_raises_rpc_error(-5, "Invalid address format", node.getaddressinfo, INVALID_ADDRESS)
118118

119-
## ELEMENTS
119+
# ELEMENTS
120120
assert_raises_rpc_error(-5, "Invalid Blech32 address data size", node.getaddressinfo, BLECH32_INVALID_SIZE)
121121

122122
assert_raises_rpc_error(-5, "Invalid prefix for Blech32 address", node.getaddressinfo, BLECH32_INVALID_PREFIX)

0 commit comments

Comments
 (0)