Skip to content

Commit

Permalink
support unisat wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
nikaJames95 committed Jan 5, 2024
1 parent d46f3be commit 93584d0
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
4 changes: 4 additions & 0 deletions framework/helper/ckb_auth_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ def verify_tron_signature(account, signature, message="00112233445566778899aabbc
def verify_dogecoin_signature(address, signMessage, message):

cmd = f"{ckb_auth_cli_path} dogecoin verify -a {address} -s {signMessage} -m {message}"
return run_command(cmd)

def verify_bitcoin_signature_byUnisat(address, signMessage, message):
cmd = f"{ckb_auth_cli_path} unisat verify -a {address} -s {signMessage} -m {message}"
return run_command(cmd)
2 changes: 0 additions & 2 deletions framework/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import string
import random
import base58
from base64 import b64decode

def get_project_root():
current_path = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -78,7 +77,6 @@ def process_solana_output(output):
return None



def check_container_status(container_name):
cmd = f"docker ps -a | grep {container_name}"
try:
Expand Down
2 changes: 1 addition & 1 deletion prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cargo install ckb-capsule --git https://github.com/nervosnetwork/capsule.git --t
echo "download ckb-auth"
git clone https://github.com/joii2020/ckb-auth.git
cd ckb-auth
git checkout dogecoin
git checkout unisat3

echo "build contract"
git submodule update --init
Expand Down
51 changes: 47 additions & 4 deletions testcases/test_bitcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from framework.helper.bitcoin_cli import *
import pytest


# @pytest.mark.skip("debug")
class TestBitcoin:
@classmethod
Expand All @@ -11,15 +12,57 @@ def setup_class(cls):

@classmethod
def teardown_class(cls):
stopBitcoind()
stopBitcoind()

def test_signMessageAndVerify(self):
address, walletName = createWalletAndAddress(self.cli, generate_random_string(5))
print(f"address: {address}, walletName: {walletName}")
signMessage, message = generateSignature(self.cli, address, walletName)
print(f"signMessage:{signMessage}")
assert signMessage is not None
result = verify_bitcoin_signature(address, signMessage, message)
assert "Signature verification succeeded!" in result
assert "Signature verification succeeded!" in result


def test_verifyMessageByUnisat(self):
"""
verify message by unisat wallet
"""
verify_cases = [
{
"address": "bc1ql9ju4rwv20k4ly7yxzev4und09wwexn9wspeta",
"signature": "HClKAE+iHiZMJN9WgJCSwT88JslZ0CsU2dbongWqSzVpFRfGTV7uy36gTn82PIvNmFpguAYtRFuBY87CLbNghX4=",
"message": "0011223344556677889900112233445500112233445566778899001122334455"
},
{
"address": "tb1ql9ju4rwv20k4ly7yxzev4und09wwexn9yk62sw",
"signature": "HAcDpCzFUF9+2WE3cUeNhX0HUCRQ3xf0p61gDZ4rjvYSePxF6zYlE5hfQob+PdClohJLV5JBwuTcjyIgOb4ZK+M=",
"message": "0011223344556677889900112233445500112233445566778899001122334455"
},
{
"address": "3HsqUZPg8BKi9q242W5fyFGGqzquPDBpWB",
"signature": "HAcDpCzFUF9+2WE3cUeNhX0HUCRQ3xf0p61gDZ4rjvYSePxF6zYlE5hfQob+PdClohJLV5JBwuTcjyIgOb4ZK+M=",
"message": "0011223344556677889900112233445500112233445566778899001122334455"
},
{
"address": "2N9S3YJKhjdq4McebhdhYbCFY4M45DqGsW5",
"signature": "HGnj9mK62Kl9l6RwnKuDZdItqDGp2VRJL0Hlv8JfMSwaewkwM1TJgZNCeJrkWEAArVo2pzihLrY/1jsELN1gDBE=",
"message": "0011223344556677889900112233445500112233445566778899001122334455"
},
{
"address": "n1rY3ZQi9YB5pMtdBvk79eyYEUsdv5K24b",
"signature": "Gz1enxNMu/IBUTuHj3PQsVCixzen/Im6mRW8tfrfFKn/MTOyPuXyAhSrHYKtmB34yGgqZnixCh6IfimbyT7gD7E=",
"message": "0011223344556677889900112233445500112233445566778899001122334455"
},
{
"address": "1MLakWKjLWjq3FR1UMmjKjmDNVGvyLk6Tc",
"signature": "G0c+GB5p6a9Dnrz/U3BzWnnAHAI5Bn2tjqG+Bm35UBQHDRHukng4n90exqSda4cEVcBbIAkEEEFikb0OIIpBPtY=",
"message": "0011223344556677889900112233445500112233445566778899001122334455"
}
]
for verify_case in verify_cases:
result = verify_bitcoin_signature_byUnisat(
verify_case["address"],
verify_case["signature"],
verify_case["message"]
)
assert "Signature verification succeeded!" in result

0 comments on commit 93584d0

Please sign in to comment.