@anywalletkit/wallet-btc 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -901,7 +901,7 @@ var WalletAccountBtc = class _WalletAccountBtc extends WalletAccountReadOnlyBtc
901
901
  ctx(intended) {
902
902
  return { network: this._network, ownAddress: this.address, intended, maxFeeRate: this.maxFeeRate };
903
903
  }
904
- async buildAndSign(plan, to, recipientValue, change, lockTime, rbf) {
904
+ async signPlan(plan, to, recipientValue, change, lockTime, rbf) {
905
905
  const spend = spendInfo(this.publicKey, this._network, this.addressType);
906
906
  const tx = new import_btc_signer4.Transaction({ lockTime });
907
907
  const sequence = rbf ? RBF_SEQUENCE : FINAL_SEQUENCE;
@@ -919,7 +919,7 @@ var WalletAccountBtc = class _WalletAccountBtc extends WalletAccountReadOnlyBtc
919
919
  * signed vsize somehow needs more, the difference comes out of change (never the
920
920
  * recipient) and the tx is re-signed once.
921
921
  */
922
- async buildSignedTransaction(spend) {
922
+ async signSpend(spend) {
923
923
  this.live();
924
924
  const plan = await this.planSpend(spend);
925
925
  await this.verifyPrevouts(plan.utxos);
@@ -927,7 +927,7 @@ var WalletAccountBtc = class _WalletAccountBtc extends WalletAccountReadOnlyBtc
927
927
  const rbf = spend.rbf ?? this._config.rbf ?? true;
928
928
  let change = plan.change;
929
929
  let fee = plan.fee;
930
- let tx = await this.buildAndSign(plan, spend.to, plan.amount, change, lockTime, rbf);
930
+ let tx = await this.signPlan(plan, spend.to, plan.amount, change, lockTime, rbf);
931
931
  const required = BigInt(tx.vsize) * plan.feeRate;
932
932
  if (required > fee) {
933
933
  const delta = required - fee;
@@ -940,7 +940,7 @@ var WalletAccountBtc = class _WalletAccountBtc extends WalletAccountReadOnlyBtc
940
940
  fee = plan.fee + plan.change;
941
941
  change = 0n;
942
942
  } else fee = required;
943
- tx = await this.buildAndSign(plan, spend.to, plan.amount, change, lockTime, rbf);
943
+ tx = await this.signPlan(plan, spend.to, plan.amount, change, lockTime, rbf);
944
944
  if (BigInt(tx.vsize) * plan.feeRate > fee) throw new Error("Fee shortfall after output rebalance.");
945
945
  }
946
946
  const ctx = this.ctx({ to: spend.to, value: plan.amount });
@@ -1011,7 +1011,7 @@ var WalletAccountBtc = class _WalletAccountBtc extends WalletAccountReadOnlyBtc
1011
1011
  /** "What you sign": the fully resolved spend (signed, NOT broadcast) or a caller's raw hex. */
1012
1012
  async describeTransaction(tx) {
1013
1013
  if (typeof tx === "string") return (await this.describeRaw(tx)).desc;
1014
- return (await this.buildSignedTransaction(tx)).desc;
1014
+ return (await this.signSpend(tx)).desc;
1015
1015
  }
1016
1016
  /** Sign without broadcasting. Returns the raw transaction hex. Raw hex input gets the checks `sendTransaction` runs (prevouts through the client) and is returned unchanged, never re-signed. */
1017
1017
  async signTransaction(tx, options = {}) {
@@ -1021,7 +1021,7 @@ var WalletAccountBtc = class _WalletAccountBtc extends WalletAccountReadOnlyBtc
1021
1021
  this.checkMax(desc.fee, (0, import_core9.feeLimit)(this._config.transactionMaxFee, options), "transaction");
1022
1022
  return tx;
1023
1023
  }
1024
- const { tx: built, fee } = await this.buildSignedTransaction(tx);
1024
+ const { tx: built, fee } = await this.signSpend(tx);
1025
1025
  this.checkMax(fee, (0, import_core9.feeLimit)(this._config.transactionMaxFee, options), "transaction");
1026
1026
  return built.hex;
1027
1027
  }
@@ -1039,7 +1039,7 @@ var WalletAccountBtc = class _WalletAccountBtc extends WalletAccountReadOnlyBtc
1039
1039
  hash = parsed.id;
1040
1040
  fee = desc.fee;
1041
1041
  } else {
1042
- const built = await this.buildSignedTransaction(tx);
1042
+ const built = await this.signSpend(tx);
1043
1043
  rawHex = built.tx.hex;
1044
1044
  hash = built.tx.id;
1045
1045
  fee = built.fee;
@@ -1053,7 +1053,7 @@ var WalletAccountBtc = class _WalletAccountBtc extends WalletAccountReadOnlyBtc
1053
1053
  if (o.token) throw new Error("Tokens are not supported on the bitcoin blockchain.");
1054
1054
  this.live();
1055
1055
  const client = this.requireClient("transfer");
1056
- const built = await this.buildSignedTransaction({ to: o.recipient, value: o.amount });
1056
+ const built = await this.signSpend({ to: o.recipient, value: o.amount });
1057
1057
  this.checkMax(built.fee, (0, import_core9.feeLimit)(this._config.transferMaxFee, writeOptions), "transfer");
1058
1058
  const txid = await client.broadcast(built.tx.hex);
1059
1059
  return { hash: txid || built.tx.id, fee: built.fee };