unisat-wallet / extension

The first open-source browser extension wallet for Bitcoin NFTs
Other
804 stars 304 forks source link

Can I use signMessage for P2sh transaction of bitcoinjs-lib ? #183

Open peter-jim opened 2 months ago

peter-jim commented 2 months ago

I want to use unisat wallet sign a transaction from bitcoinjs-lib P2sh method,I dont know wether does unisat support it? bitcoinjs lib need Buffer and unisat sign message result like is "IOLAT1IwkrkGZD2TU6y4t/uUbB0PqiKKdeOVBzTmYb+dCZF53krwncQvThMKwgwwBPEHCS28jr" ,which diffrent from bitcoinjs lib .

here is bitcoinjs-lib code


const secret = Buffer.from('123', 'utf-8'); 
const secretHash = bitcoin.crypto.sha256(secret);// 
const signature =  bitcoin.script.signature.encode(alice.sign(signatureHash), hashType);

alice sign hash is a2352194251ce99bc98a877bc01b09d377fa0ea9a567bc9a843eb7585dc9ab966b753468bc0f340352b9b68cb57b3ad39090c89dda4078beb308273a1127cac8

secretHash is a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3 unisat code

// sign by ecdsa
        try {
            let unisatSign = window.unisat.signMessage('a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3');
            console.log("unisatSign",unisatSign);
        } catch (e) {
            console.log(e);
        }

I got this IOLAT1IwkrkGZD2TU6y4t/uUbB0PqiKKdeOVBzTmYb+dCZF53krwncQvThMKwgwwBPEHCS28jrx2pmJXb9KmSYk=

GGG888GGG commented 2 months ago

@huanniangstudio @abangZ