@causeway-sh/btc
v0.1.0-alpha.4
Published
Causeway BTC helpers for TypeScript — P2TR address derivation, BIP-341 sighash, witness assembly, bitcoind RPC client.
Readme
@causeway-sh/btc
Bitcoin off-chain helpers for Causeway. P2TR
(Taproot key-spend) vault addresses, BIP-341 sighash construction,
witness assembly, and a small bitcoind JSON-RPC client.
Install
pnpm add @causeway-sh/core@alpha @causeway-sh/btc@alphaQuickstart
import {
deriveVaultAddress,
buildUnsignedTx,
assembleSignedTx,
BitcoindRpcClient,
} from "@causeway-sh/btc";
const v = deriveVaultAddress({
vaultThresholdPubkey, // 33 bytes — from the on-chain Vault account
tenant, // 32 bytes — the tenant program's id
derivationPath, // canonical Causeway path bytes
network: "mainnet",
});
console.log(v.address); // "bc1p…"
const { unsignedTx, sighash } = buildUnsignedTx({ /* ... */ });
// run threshold Schnorr signing round on `sighash`,
// receive a 64-byte signature, then:
const signedRawTx = assembleSignedTx({ tx: unsignedTx, schnorrSignature });
const rpc = new BitcoindRpcClient({ url: "...", auth: "..." });
const txid = await rpc.sendRawTransaction(signedRawTx);API
deriveVaultAddress({ vaultThresholdPubkey, tenant, derivationPath, network })— Causeway tweak → BIP-341 TapTweak → bech32m. Returns{ address, outputKey, internalKey }.network: "mainnet" | "testnet4".buildUnsignedTx(plan)— single-input single-output unsigned tx plus the 32-byte BIP-341 key-spend sighash.assembleSignedTx({ tx, schnorrSignature })— splice the 64-byte Schnorr signature into the input-0 witness; returns raw bytes ready forsendrawtransaction.BitcoindRpcClient— minimalsendrawtransaction/gettxout/getblockcountJSON-RPC client.
Scope
M1 shape: single-input, single-output, P2TR key-spend. No multi-input
UTXO selection, no fee estimation. Use a fee oracle of your choice
and pass the totals into buildUnsignedTx.
Status
Alpha. Bitcoin mainnet broadcasts have completed end-to-end through this SDK. The on-chain program is unverified bytecode and the protocol is not audited. Do not move funds you can't afford to lose.
License
Links
- Repository — https://github.com/causeway-protocol/sdk-ts
- Protocol — https://causeway.sh
