From d24f13d4997fe0fb06a5ef2aae29f10415d07d89 Mon Sep 17 00:00:00 2001 From: Mahmoud Aboelenein Date: Mon, 1 Apr 2024 14:19:33 +0200 Subject: [PATCH] updated getAccounts and senTransfer adapters --- src/adapters/unisat.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/adapters/unisat.ts b/src/adapters/unisat.ts index 07b91cb..e23e311 100644 --- a/src/adapters/unisat.ts +++ b/src/adapters/unisat.ts @@ -80,15 +80,16 @@ class UnisatAdapter extends SatsConnectAdapter { ]); const address = accounts[0]; const addressType = getAddressInfo(accounts[0]).type; + const pk = addressType === AddressType.p2tr ? publicKey.slice(2) : publicKey; const paymentAddress: Address = { address, - publicKey, + publicKey: pk, addressType, purpose: AddressPurpose.Payment, }; const ordinalsAddress: Address = { address, - publicKey, + publicKey: pk, addressType, purpose: AddressPurpose.Ordinals, }; @@ -124,11 +125,13 @@ class UnisatAdapter extends SatsConnectAdapter { private async sendTransfer(params: SendTransferParams): Promise> { const { recipients } = params; - const response = await Promise.all( - recipients.map((recipient) => window.unisat.sendBitcoin(recipient.address, recipient.amount)) - ); + if (recipients.length > 1) { + throw new Error('Only one recipient is supported by this wallet provider'); + } + const txid = await window.unisat.sendBitcoin(recipients[0].address, recipients[0].amount); + return { - txid: response[0], + txid, }; }