Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions depends/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ include packages/packages.mk
# 2. Before including packages/*.mk (excluding packages/packages.mk), since
# they rely on the build_id variables
#
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))')
$(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))')
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))')
$(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))')

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

Expand Down
7 changes: 5 additions & 2 deletions depends/gen_id
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash

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

echo "BEGIN CXX"
bash -c "${CXX} -v"
bash -c "${CXX} -v -E -xc++ -o /dev/null - < /dev/null"
bash -c "${CXX} -v -E -xobjective-c++ -o /dev/null - < /dev/null"
echo "CXX_STANDARD=${CXX_STANDARD}"
echo "END CXX"

echo "BEGIN AR"
Expand Down
28 changes: 14 additions & 14 deletions test/functional/test_framework/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ class MiniWallet:
def __init__(self, test_node, *, mode=MiniWalletMode.ADDRESS_OP_TRUE):
self._test_node = test_node
self._utxos = []
self._priv_key = None
self._address = None
self._mode = mode

assert isinstance(mode, MiniWalletMode)
if mode == MiniWalletMode.RAW_OP_TRUE:
Expand Down Expand Up @@ -113,7 +112,7 @@ def scan_tx(self, tx):

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

def get_address(self):
assert_equal(self._mode, MiniWalletMode.ADDRESS_OP_TRUE)
return self._address

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

tx = CTransaction()
tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']), nSequence=sequence)]
tx.vout = [CTxOut(send_value, self._scriptPubKey)]
tx.nLockTime = locktime
if not self._address:
# raw script
if self._priv_key is not None:
# P2PK, need to sign
self.sign_tx(tx)
else:
# anyone-can-spend
tx.vin[0].scriptSig = CScript([OP_NOP] * 24) # pad to identical size
else:
if self._mode == MiniWalletMode.RAW_P2PK:
self.sign_tx(tx)
elif self._mode == MiniWalletMode.RAW_OP_TRUE:
tx.vin[0].scriptSig = CScript([OP_NOP] * 24) # pad to identical size
elif self._mode == MiniWalletMode.ADDRESS_OP_TRUE:
tx.vin[0].scriptSig = CScript([CScript([OP_TRUE])])
else:
assert False
tx_hex = tx.serialize().hex()

tx_info = from_node.testmempoolaccept([tx_hex])[0]
Expand Down
Loading