Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.
This repository was archived by the owner on May 27, 2025. It is now read-only.

Wrap BTC APIs to support wallet/signer interface #32

@ShookLyngs

Description

@ShookLyngs

Feature request

Currently the BTC APIs are designed to return a PSBT, like the following exmaple:

// Build
const psbt = await sendBtc({
  from: account.address,
  to: {
    address: 'btc_to_address',
    value: 10000,
  },
  source,
});

// Sign
psbt.signAllInputs(account.keyPair);
psbt.finalizeAllInputs();

// Broadcast
const tx = psbt.extractTransaction();
const txid = await service.sendTransaction(tx.toHex());

@duanyytop wish the build/sign/send process can be wrapped/simplified to a single call, like:

const txid = await sendBtc({
  from: signer,
  to: {
    address: 'btc_to_address',
    value: 10000,
  },
  source,
  service,
});

Estimation

In my mind, it would take some steps to support this feature:

  1. Keep the current design of the BTC APIs, but rename them to be more accurate (sendBtc -> buildSendBtcTx)
  2. Design a Wallet interface that provides publicKey, address and signTransaction to the APIs
  3. Wrap BTC APIs to create new APIs and accept wallet/signer as prop, simplifying things

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions