Explicitly set messagemagic string for Particl v27

This commit is contained in:
tecnovert
2025-08-04 21:27:16 +02:00
parent 9cc4734bda
commit 235a8f6830
3 changed files with 27 additions and 29 deletions

View File

@@ -1981,6 +1981,15 @@ class BTCInterface(Secp256k1Interface):
sum_unspent += self.make_int(o["amount"])
return sum_unspent
def signMessage(self, address: str, message: str) -> str:
return self.rpc_wallet(
"signmessage",
[address, message],
)
def signMessageWithKey(self, key_wif: str, message: str) -> str:
return self.rpc("signmessagewithprivkey", [key_wif, message])
def getProofOfFunds(self, amount_for, extra_commit_bytes):
# TODO: Lock unspent and use same output/s to fund bid
unspent_addr = self.getUnspentsByAddr()
@@ -1998,6 +2007,7 @@ class BTCInterface(Secp256k1Interface):
self._log.debug(f"sign_for_addr {sign_for_addr}")
funds_addr: str = sign_for_addr
if (
self.using_segwit()
): # TODO: Use isSegwitAddress when scantxoutset can use combo
@@ -2006,6 +2016,7 @@ class BTCInterface(Secp256k1Interface):
sign_for_addr = self.pkh_to_address(pkh)
self._log.debug(f"sign_for_addr converted {sign_for_addr}")
sign_message: str = sign_for_addr + "_swap_proof_" + extra_commit_bytes.hex()
if self._use_descriptors:
# https://github.com/bitcoin/bitcoin/issues/10542
# https://github.com/bitcoin/bitcoin/issues/26046
@@ -2022,7 +2033,6 @@ class BTCInterface(Secp256k1Interface):
],
)
hdkeypath = addr_info["hdkeypath"]
sign_for_address_key = None
for descriptor in priv_keys["descriptors"]:
if descriptor["active"] is False or descriptor["internal"] is True:
@@ -2043,22 +2053,10 @@ class BTCInterface(Secp256k1Interface):
sign_for_address_key = self.encodeKey(ek._key)
break
assert sign_for_address_key is not None
signature = self.rpc(
"signmessagewithprivkey",
[
sign_for_address_key,
sign_for_addr + "_swap_proof_" + extra_commit_bytes.hex(),
],
)
signature = self.signMessageWithKey(sign_for_address_key, sign_message)
del priv_keys
else:
signature = self.rpc_wallet(
"signmessage",
[
sign_for_addr,
sign_for_addr + "_swap_proof_" + extra_commit_bytes.hex(),
],
)
signature = self.signMessage(sign_for_addr, sign_message)
prove_utxos = [] # TODO: Send specific utxos
return (sign_for_addr, signature, prove_utxos)