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 = OfferRevokeMessage()
|
||||||
msg_buf.offer_msg_id = offer_id
|
msg_buf.offer_msg_id = offer_id
|
||||||
|
|
||||||
signature_enc = self.callcoinrpc(
|
signature_enc = self.ci(Coins.PART).signMessage(
|
||||||
Coins.PART, "signmessage", [offer.addr_from, offer_id.hex() + "_revoke"]
|
offer.addr_from, offer_id.hex() + "_revoke"
|
||||||
)
|
)
|
||||||
|
|
||||||
msg_buf.signature = base64.b64decode(signature_enc)
|
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")
|
signature_enc = base64.b64encode(msg_data.signature).decode("UTF-8")
|
||||||
|
|
||||||
passed = self.callcoinrpc(
|
passed = self.ci(Coins.PART).verifyMessage(
|
||||||
Coins.PART,
|
offer.addr_from, signature_enc, msg_data.offer_msg_id.hex() + "_revoke"
|
||||||
"verifymessage",
|
|
||||||
[
|
|
||||||
offer.addr_from,
|
|
||||||
signature_enc,
|
|
||||||
msg_data.offer_msg_id.hex() + "_revoke",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
ensure(passed is True, "Signature invalid")
|
ensure(passed is True, "Signature invalid")
|
||||||
|
|
||||||
@@ -12100,10 +12094,8 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
|||||||
for pair in self._possibly_revoked_offers:
|
for pair in self._possibly_revoked_offers:
|
||||||
if offer_id == pair[0]:
|
if offer_id == pair[0]:
|
||||||
signature_enc = base64.b64encode(pair[1]).decode("UTF-8")
|
signature_enc = base64.b64encode(pair[1]).decode("UTF-8")
|
||||||
passed = self.callcoinrpc(
|
passed = self.ci(Coins.PART).verifyMessage(
|
||||||
Coins.PART,
|
offer_addr_from, signature_enc, offer_id.hex() + "_revoke"
|
||||||
"verifymessage",
|
|
||||||
[offer_addr_from, signature_enc, offer_id.hex() + "_revoke"],
|
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
True if passed is True else False
|
True if passed is True else False
|
||||||
|
|||||||
@@ -1981,6 +1981,15 @@ class BTCInterface(Secp256k1Interface):
|
|||||||
sum_unspent += self.make_int(o["amount"])
|
sum_unspent += self.make_int(o["amount"])
|
||||||
return sum_unspent
|
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):
|
def getProofOfFunds(self, amount_for, extra_commit_bytes):
|
||||||
# TODO: Lock unspent and use same output/s to fund bid
|
# TODO: Lock unspent and use same output/s to fund bid
|
||||||
unspent_addr = self.getUnspentsByAddr()
|
unspent_addr = self.getUnspentsByAddr()
|
||||||
@@ -1998,6 +2007,7 @@ class BTCInterface(Secp256k1Interface):
|
|||||||
self._log.debug(f"sign_for_addr {sign_for_addr}")
|
self._log.debug(f"sign_for_addr {sign_for_addr}")
|
||||||
|
|
||||||
funds_addr: str = sign_for_addr
|
funds_addr: str = sign_for_addr
|
||||||
|
|
||||||
if (
|
if (
|
||||||
self.using_segwit()
|
self.using_segwit()
|
||||||
): # TODO: Use isSegwitAddress when scantxoutset can use combo
|
): # TODO: Use isSegwitAddress when scantxoutset can use combo
|
||||||
@@ -2006,6 +2016,7 @@ class BTCInterface(Secp256k1Interface):
|
|||||||
sign_for_addr = self.pkh_to_address(pkh)
|
sign_for_addr = self.pkh_to_address(pkh)
|
||||||
self._log.debug(f"sign_for_addr converted {sign_for_addr}")
|
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:
|
if self._use_descriptors:
|
||||||
# https://github.com/bitcoin/bitcoin/issues/10542
|
# https://github.com/bitcoin/bitcoin/issues/10542
|
||||||
# https://github.com/bitcoin/bitcoin/issues/26046
|
# https://github.com/bitcoin/bitcoin/issues/26046
|
||||||
@@ -2022,7 +2033,6 @@ class BTCInterface(Secp256k1Interface):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
hdkeypath = addr_info["hdkeypath"]
|
hdkeypath = addr_info["hdkeypath"]
|
||||||
|
|
||||||
sign_for_address_key = None
|
sign_for_address_key = None
|
||||||
for descriptor in priv_keys["descriptors"]:
|
for descriptor in priv_keys["descriptors"]:
|
||||||
if descriptor["active"] is False or descriptor["internal"] is True:
|
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)
|
sign_for_address_key = self.encodeKey(ek._key)
|
||||||
break
|
break
|
||||||
assert sign_for_address_key is not None
|
assert sign_for_address_key is not None
|
||||||
signature = self.rpc(
|
signature = self.signMessageWithKey(sign_for_address_key, sign_message)
|
||||||
"signmessagewithprivkey",
|
|
||||||
[
|
|
||||||
sign_for_address_key,
|
|
||||||
sign_for_addr + "_swap_proof_" + extra_commit_bytes.hex(),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
del priv_keys
|
del priv_keys
|
||||||
else:
|
else:
|
||||||
signature = self.rpc_wallet(
|
signature = self.signMessage(sign_for_addr, sign_message)
|
||||||
"signmessage",
|
|
||||||
[
|
|
||||||
sign_for_addr,
|
|
||||||
sign_for_addr + "_swap_proof_" + extra_commit_bytes.hex(),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
prove_utxos = [] # TODO: Send specific utxos
|
prove_utxos = [] # TODO: Send specific utxos
|
||||||
return (sign_for_addr, signature, prove_utxos)
|
return (sign_for_addr, signature, prove_utxos)
|
||||||
|
|||||||
@@ -190,6 +190,14 @@ class PARTInterface(BTCInterface):
|
|||||||
def combine_non_segwit_prevouts(self):
|
def combine_non_segwit_prevouts(self):
|
||||||
raise RuntimeError("No non-segwit outputs found.")
|
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):
|
class PARTInterfaceBlind(PARTInterface):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user