mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
Explicitly set messagemagic string for Particl v27
This commit is contained in:
@@ -2399,8 +2399,8 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
msg_buf = OfferRevokeMessage()
|
||||
msg_buf.offer_msg_id = offer_id
|
||||
|
||||
signature_enc = self.callcoinrpc(
|
||||
Coins.PART, "signmessage", [offer.addr_from, offer_id.hex() + "_revoke"]
|
||||
signature_enc = self.ci(Coins.PART).signMessage(
|
||||
offer.addr_from, offer_id.hex() + "_revoke"
|
||||
)
|
||||
|
||||
msg_buf.signature = base64.b64decode(signature_enc)
|
||||
@@ -7773,14 +7773,8 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
|
||||
signature_enc = base64.b64encode(msg_data.signature).decode("UTF-8")
|
||||
|
||||
passed = self.callcoinrpc(
|
||||
Coins.PART,
|
||||
"verifymessage",
|
||||
[
|
||||
offer.addr_from,
|
||||
signature_enc,
|
||||
msg_data.offer_msg_id.hex() + "_revoke",
|
||||
],
|
||||
passed = self.ci(Coins.PART).verifyMessage(
|
||||
offer.addr_from, signature_enc, msg_data.offer_msg_id.hex() + "_revoke"
|
||||
)
|
||||
ensure(passed is True, "Signature invalid")
|
||||
|
||||
@@ -12100,10 +12094,8 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
for pair in self._possibly_revoked_offers:
|
||||
if offer_id == pair[0]:
|
||||
signature_enc = base64.b64encode(pair[1]).decode("UTF-8")
|
||||
passed = self.callcoinrpc(
|
||||
Coins.PART,
|
||||
"verifymessage",
|
||||
[offer_addr_from, signature_enc, offer_id.hex() + "_revoke"],
|
||||
passed = self.ci(Coins.PART).verifyMessage(
|
||||
offer_addr_from, signature_enc, offer_id.hex() + "_revoke"
|
||||
)
|
||||
return (
|
||||
True if passed is True else False
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -190,6 +190,14 @@ class PARTInterface(BTCInterface):
|
||||
def combine_non_segwit_prevouts(self):
|
||||
raise RuntimeError("No non-segwit outputs found.")
|
||||
|
||||
def signMessage(self, address: str, message: str) -> str:
|
||||
message_magic: str = self.chainparams()["message_magic"]
|
||||
return self.rpc_wallet("signmessage", [address, message, message_magic])
|
||||
|
||||
def signMessageWithKey(self, key_wif: str, message: str) -> str:
|
||||
message_magic: str = self.chainparams()["message_magic"]
|
||||
return self.rpc("signmessagewithprivkey", [key_wif, message, message_magic])
|
||||
|
||||
|
||||
class PARTInterfaceBlind(PARTInterface):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user