Skip to content

Commit a043110

Browse files
Merge #6518: backport: Merge bitcoin#25430, 25394
af649ce Merge bitcoin#25394: build: add *_STANDARD vars to depends gen_id (fanquake) 8c439b0 Merge bitcoin#25430: test: refactor: save MiniWallet mode explicitly (MacroFake) Pull request description: bitcoin backport cryptotura ACKs for top commit: UdjinM6: utACK af649ce knst: utACK af649ce Tree-SHA512: 811d1dbfaf4b06943d090b81f1b8ce1d0a5ca84a4690f094ca7243596a60238eb2ca60c919ffc44e0fb2582a2dab9a88ca93fe5828b3407fb6ca1ce1a75538dc
2 parents fcfe82f + af649ce commit a043110

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

depends/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ include packages/packages.mk
144144
# 2. Before including packages/*.mk (excluding packages/packages.mk), since
145145
# they rely on the build_id variables
146146
#
147-
build_id:=$(shell env CC='$(build_CC)' CXX='$(build_CXX)' AR='$(build_AR)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' ./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
148-
$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' CXX='$(host_CXX)' AR='$(host_AR)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' ./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
147+
build_id:=$(shell env CC='$(build_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(build_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(build_AR)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' ./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
148+
$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(host_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(host_AR)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' ./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
149149

150150
qrencode_packages_$(NO_QR) = $(qrencode_$(host_os)_packages)
151151

depends/gen_id

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env bash
22

3-
# Usage: env [ CC=... ] [ CXX=... ] [ AR=... ] [ RANLIB=... ] [ STRIP=... ] \
4-
# [ DEBUG=... ] [ LTO=... ] ./build-id [ID_SALT]...
3+
# Usage: env [ CC=... ] [ C_STANDARD=...] [ CXX=... ] [CXX_STANDARD=...] \
4+
# [ AR=... ] [ RANLIB=... ] [ STRIP=... ] [ DEBUG=... ] \
5+
# [ LTO=... ] ./build-id [ID_SALT]...
56
#
67
# Prints to stdout a SHA256 hash representing the current toolset, used by
78
# depends/Makefile as a build id for caching purposes (detecting when the
@@ -39,12 +40,14 @@
3940
bash -c "${CC} -v"
4041
bash -c "${CC} -v -E -xc -o /dev/null - < /dev/null"
4142
bash -c "${CC} -v -E -xobjective-c -o /dev/null - < /dev/null"
43+
echo "C_STANDARD=${C_STANDARD}"
4244
echo "END CC"
4345

4446
echo "BEGIN CXX"
4547
bash -c "${CXX} -v"
4648
bash -c "${CXX} -v -E -xc++ -o /dev/null - < /dev/null"
4749
bash -c "${CXX} -v -E -xobjective-c++ -o /dev/null - < /dev/null"
50+
echo "CXX_STANDARD=${CXX_STANDARD}"
4851
echo "END CXX"
4952

5053
echo "BEGIN AR"

test/functional/test_framework/wallet.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ class MiniWallet:
7474
def __init__(self, test_node, *, mode=MiniWalletMode.ADDRESS_OP_TRUE):
7575
self._test_node = test_node
7676
self._utxos = []
77-
self._priv_key = None
78-
self._address = None
77+
self._mode = mode
7978

8079
assert isinstance(mode, MiniWalletMode)
8180
if mode == MiniWalletMode.RAW_OP_TRUE:
@@ -113,7 +112,7 @@ def scan_tx(self, tx):
113112

114113
def sign_tx(self, tx, fixed_length=True):
115114
"""Sign tx that has been created by MiniWallet in P2PK mode"""
116-
assert self._priv_key is not None
115+
assert_equal(self._mode, MiniWalletMode.RAW_P2PK)
117116
(sighash, err) = SignatureHash(CScript(self._scriptPubKey), tx, 0, SIGHASH_ALL)
118117
assert err is None
119118
# for exact fee calculation, create only signatures with fixed size by default (>49.89% probability):
@@ -142,6 +141,7 @@ def get_descriptor(self):
142141
return descsum_create(f'raw({self._scriptPubKey.hex()})')
143142

144143
def get_address(self):
144+
assert_equal(self._mode, MiniWalletMode.ADDRESS_OP_TRUE)
145145
return self._address
146146

147147
def get_utxo(self, *, txid: str = '', vout: Optional[int] = None, mark_as_spent=True):
@@ -193,27 +193,27 @@ def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utx
193193
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
194194
from_node = from_node or self._test_node
195195
utxo_to_spend = utxo_to_spend or self.get_utxo()
196-
if self._priv_key is None:
196+
if self._mode in (MiniWalletMode.RAW_OP_TRUE, MiniWalletMode.ADDRESS_OP_TRUE):
197197
vsize = Decimal(85) # anyone-can-spend
198-
else:
198+
elif self._mode == MiniWalletMode.RAW_P2PK:
199199
vsize = Decimal(168) # P2PK (73 bytes scriptSig + 35 bytes scriptPubKey + 60 bytes other)
200+
else:
201+
assert False
200202
send_value = int(COIN * (utxo_to_spend['value'] - fee_rate * (vsize / 1000)))
201203
assert send_value > 0
202204

203205
tx = CTransaction()
204206
tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']), nSequence=sequence)]
205207
tx.vout = [CTxOut(send_value, self._scriptPubKey)]
206208
tx.nLockTime = locktime
207-
if not self._address:
208-
# raw script
209-
if self._priv_key is not None:
210-
# P2PK, need to sign
211-
self.sign_tx(tx)
212-
else:
213-
# anyone-can-spend
214-
tx.vin[0].scriptSig = CScript([OP_NOP] * 24) # pad to identical size
215-
else:
209+
if self._mode == MiniWalletMode.RAW_P2PK:
210+
self.sign_tx(tx)
211+
elif self._mode == MiniWalletMode.RAW_OP_TRUE:
212+
tx.vin[0].scriptSig = CScript([OP_NOP] * 24) # pad to identical size
213+
elif self._mode == MiniWalletMode.ADDRESS_OP_TRUE:
216214
tx.vin[0].scriptSig = CScript([CScript([OP_TRUE])])
215+
else:
216+
assert False
217217
tx_hex = tx.serialize().hex()
218218

219219
tx_info = from_node.testmempoolaccept([tx_hex])[0]

0 commit comments

Comments
 (0)