protocol: Enable private offers

Users can send private offers that will only be seen by one address.

To send a private offer:
 1. recipient creates a new address to receive offers on
 2. recipient sends the pubkey for the newly created address to the offerer
 3. offerer imports the recipient's pubkey
 4. offerer sends a new offer to the recipients key instead of the public network

Nodes will ignore offers sent on keys other than the network key or keys created for offer-receiving.
This commit is contained in:
tecnovert
2021-10-20 19:47:49 +02:00
parent f63815b26b
commit a40519737d
15 changed files with 217 additions and 38 deletions

View File

@@ -21,7 +21,7 @@ from coincurve.ecdsaotves import (
from coincurve.keys import (
PrivateKey)
from basicswap.ecc_util import i2b
from basicswap.ecc_util import i2b, h2b
from basicswap.interface_btc import BTCInterface
from basicswap.interface_xmr import XMRInterface
@@ -206,6 +206,13 @@ class Test(unittest.TestCase):
assert(len(sig) == 64)
ci.verifyCompact(pk, 'test signing message', sig)
def test_pubkey_to_address(self):
coin_settings = {'rpcport': 0, 'rpcauth': 'none', 'blocks_confirmed': 1, 'conf_target': 1}
ci = BTCInterface(coin_settings, 'regtest')
pk = h2b('02c26a344e7d21bcc6f291532679559f2fd234c881271ff98714855edc753763a6')
addr = ci.pubkey_to_address(pk)
assert(addr == 'mj6SdSxmWRmdDqR5R3FfZmRiLmQfQAsLE8')
def test_dleag(self):
coin_settings = {'rpcport': 0, 'walletrpcport': 0, 'walletrpcauth': 'none', 'blocks_confirmed': 1, 'conf_target': 1}
ci = XMRInterface(coin_settings, 'regtest')