Repository Public
1import { bchIsP2sh, encodeBchInputs, estimateBchSize, type NetworkDef } from '@spw/core';2import { utxoAdapter, type Source } from './btc.ts';3import type { Adapter } from './rpc.ts';45/**6 * Bitcoin Cash: same indexer sources and coin selection as the other Bitcoin-style chains (two independent indexers must agree7 * on the spendable coin set); the intent carries the coins in the plugin section `x`. No previous transactions are needed:8 * the signature digest commits to every input value. Chain identity is the first block after the last chain split (registry9 * `refHeight`, block 661648), because the genesis block is also Bitcoin's, Bitcoin SV's and eCash's.10 */11export function bchAdapter(n: NetworkDef, sources?: Source[]): Adapter {12 return utxoAdapter(n, {13 size: (k, to, hasChange) => estimateBchSize(k, bchIsP2sh(n, to), hasChange),14 section: async (chosen, change, fee) => ({ section: { x: { inputs: encodeBchInputs(chosen), change: change.toString(), fee: fee.toString() } } }),15 }, sources);16}17