Skip to content

Commit

Permalink
updated getAccounts and senTransfer adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
m-aboelenein committed Apr 1, 2024
1 parent f3076a8 commit d24f13d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/adapters/unisat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -124,11 +125,13 @@ class UnisatAdapter extends SatsConnectAdapter {

private async sendTransfer(params: SendTransferParams): Promise<Return<'sendTransfer'>> {
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,
};
}

Expand Down

0 comments on commit d24f13d

Please sign in to comment.