@leather.io/bitcoin
Advanced tools
| import { HARDENED_OFFSET, HDKey } from '@scure/bip32'; | ||
| import * as btc from '@scure/btc-signer'; | ||
| import { P2Ret, P2TROut } from '@scure/btc-signer/payment'; | ||
| import { SigHash } from '@scure/btc-signer/transaction'; | ||
| import * as bitcoin from 'bitcoinjs-lib'; | ||
| import { | ||
| DerivationPathDepth, | ||
| appendAddressIndexToPath, | ||
| decomposeDescriptor, | ||
| deriveKeychainFromXpub, | ||
| extractAddressIndexFromPath, | ||
| extractChangeIndexFromPath, | ||
| fingerprintAsNumberToHex, | ||
| keyOriginToDerivationPath, | ||
| } from '@leather.io/crypto'; | ||
| import type { BitcoinAddress, BitcoinNetworkModes, ValueOf } from '@leather.io/models'; | ||
| import { signatureHash } from '@leather.io/rpc'; | ||
| import { hexToNumber } from '@leather.io/utils'; | ||
| import { getTaprootPaymentFromAddressIndex } from '../payments/p2tr-address-gen'; | ||
| import { getNativeSegwitPaymentFromAddressIndex } from '../payments/p2wpkh-address-gen'; | ||
| import { | ||
| SupportedPaymentType, | ||
| ecdsaPublicKeyToSchnorr, | ||
| extractExtendedPublicKeyFromPolicy, | ||
| inferPaymentTypeFromPath, | ||
| whenSupportedPaymentType, | ||
| } from '../utils/bitcoin.utils'; | ||
| export type AllowedSighashTypes = ValueOf<typeof signatureHash> | SigHash; | ||
| export interface BitcoinAccountKeychain { | ||
| descriptor: string; | ||
| masterKeyFingerprint: string; | ||
| keyOrigin: string; | ||
| keychain: HDKey; | ||
| xpub: string; | ||
| } | ||
| export type WithDerivePayer<T, P extends BitcoinPayer> = T & { | ||
| derivePayer(args: BitcoinPayerInfo): P; | ||
| }; | ||
| export interface BitcoinPayerBase { | ||
| paymentType: SupportedPaymentType; | ||
| network: BitcoinNetworkModes; | ||
| address: BitcoinAddress; | ||
| keyOrigin: string; | ||
| masterKeyFingerprint: string; | ||
| publicKey: Uint8Array; | ||
| } | ||
| export interface BitcoinNativeSegwitPayer extends BitcoinPayerBase { | ||
| paymentType: 'p2wpkh'; | ||
| payment: P2Ret; | ||
| } | ||
| export interface BitcoinTaprootPayer extends BitcoinPayerBase { | ||
| paymentType: 'p2tr'; | ||
| payment: P2TROut; | ||
| } | ||
| export type BitcoinPayer = BitcoinNativeSegwitPayer | BitcoinTaprootPayer; | ||
| export function initializeBitcoinAccountKeychainFromDescriptor( | ||
| descriptor: string | ||
| ): BitcoinAccountKeychain { | ||
| const { fingerprint, keyOrigin } = decomposeDescriptor(descriptor); | ||
| return { | ||
| descriptor, | ||
| xpub: extractExtendedPublicKeyFromPolicy(descriptor), | ||
| keyOrigin, | ||
| masterKeyFingerprint: fingerprint, | ||
| keychain: deriveKeychainFromXpub(extractExtendedPublicKeyFromPolicy(descriptor)), | ||
| }; | ||
| } | ||
| export interface BitcoinPayerInfo { | ||
| change: number; | ||
| addressIndex: number; | ||
| } | ||
| export function deriveBitcoinPayerFromAccount(descriptor: string, network: BitcoinNetworkModes) { | ||
| const { fingerprint, keyOrigin } = decomposeDescriptor(descriptor); | ||
| const accountKeychain = deriveKeychainFromXpub(extractExtendedPublicKeyFromPolicy(descriptor)); | ||
| const paymentType = inferPaymentTypeFromPath(keyOrigin) as SupportedPaymentType; | ||
| if (accountKeychain.depth !== DerivationPathDepth.Account) | ||
| throw new Error('Keychain passed is not an account'); | ||
| return ({ change, addressIndex }: BitcoinPayerInfo) => { | ||
| const childKeychain = accountKeychain.deriveChild(change).deriveChild(addressIndex); | ||
| const derivePayerFromAccount = whenSupportedPaymentType(paymentType)({ | ||
| p2tr: getTaprootPaymentFromAddressIndex, | ||
| p2wpkh: getNativeSegwitPaymentFromAddressIndex, | ||
| }); | ||
| const payment = derivePayerFromAccount(childKeychain, network); | ||
| return { | ||
| keyOrigin: appendAddressIndexToPath(keyOrigin, change, addressIndex), | ||
| masterKeyFingerprint: fingerprint, | ||
| paymentType, | ||
| network, | ||
| payment, | ||
| get address() { | ||
| if (!payment.address) throw new Error('Payment address could not be derived'); | ||
| return payment.address; | ||
| }, | ||
| get publicKey() { | ||
| if (!childKeychain.publicKey) throw new Error('Public key could not be derived'); | ||
| return childKeychain.publicKey; | ||
| }, | ||
| }; | ||
| }; | ||
| } | ||
| interface BtcSignerDerivationPath { | ||
| fingerprint: number; | ||
| path: number[]; | ||
| } | ||
| export type BtcSignerDefaultBip32Derivation = [Uint8Array, BtcSignerDerivationPath]; | ||
| export type BtcSignerTapBip32Derivation = [ | ||
| Uint8Array, | ||
| { hashes: Uint8Array[]; der: BtcSignerDerivationPath }, | ||
| ]; | ||
| type BtcSignerBip32Derivation = BtcSignerDefaultBip32Derivation | BtcSignerTapBip32Derivation; | ||
| type PayerToBip32DerivationArgs = Pick< | ||
| BitcoinPayer, | ||
| 'masterKeyFingerprint' | 'keyOrigin' | 'publicKey' | ||
| >; | ||
| /** | ||
| * @example | ||
| * ```ts | ||
| * tx.addInput({ | ||
| * ...input, | ||
| * bip32Derivation: [payerToBip32Derivation(payer)], | ||
| * }) | ||
| * ``` | ||
| */ | ||
| export function payerToBip32Derivation( | ||
| args: PayerToBip32DerivationArgs | ||
| ): BtcSignerDefaultBip32Derivation { | ||
| return [ | ||
| args.publicKey, | ||
| { | ||
| fingerprint: hexToNumber(args.masterKeyFingerprint), | ||
| path: btc.bip32Path(keyOriginToDerivationPath(args.keyOrigin)), | ||
| }, | ||
| ]; | ||
| } | ||
| /** | ||
| * @example | ||
| * ```ts | ||
| * tx.addInput({ | ||
| * ...input, | ||
| * tapBip32Derivation: [payerToTapBip32Derivation(payer)], | ||
| * }) | ||
| * ``` | ||
| */ | ||
| export function payerToTapBip32Derivation( | ||
| args: PayerToBip32DerivationArgs | ||
| ): BtcSignerTapBip32Derivation { | ||
| return [ | ||
| // TODO: @kyranjamie to default to schnoor when TR so conversion isn't | ||
| // necessary here? | ||
| ecdsaPublicKeyToSchnorr(args.publicKey), | ||
| { | ||
| hashes: [], | ||
| der: { | ||
| fingerprint: hexToNumber(args.masterKeyFingerprint), | ||
| path: btc.bip32Path(keyOriginToDerivationPath(args.keyOrigin)), | ||
| }, | ||
| }, | ||
| ]; | ||
| } | ||
| type PsbtInputBitcoinJsLib = bitcoin.Psbt['data']['inputs']['0']; | ||
| type TapBip32DerivationBitcoinJsLib = NonNullable<PsbtInputBitcoinJsLib['tapBip32Derivation']>['0']; | ||
| export function payerToTapBip32DerivationBitcoinJsLib( | ||
| args: PayerToBip32DerivationArgs | ||
| ): TapBip32DerivationBitcoinJsLib { | ||
| return { | ||
| masterFingerprint: Buffer.from(args.masterKeyFingerprint, 'hex'), | ||
| path: keyOriginToDerivationPath(args.keyOrigin), | ||
| leafHashes: [], | ||
| pubkey: Buffer.from(ecdsaPublicKeyToSchnorr(args.publicKey)), | ||
| }; | ||
| } | ||
| type Bip32DerivationBitcoinJsLib = NonNullable<PsbtInputBitcoinJsLib['bip32Derivation']>['0']; | ||
| export function payerToBip32DerivationBitcoinJsLib( | ||
| args: PayerToBip32DerivationArgs | ||
| ): Bip32DerivationBitcoinJsLib { | ||
| return { | ||
| masterFingerprint: Buffer.from(args.masterKeyFingerprint, 'hex'), | ||
| path: keyOriginToDerivationPath(args.keyOrigin), | ||
| pubkey: Buffer.from(args.publicKey), | ||
| }; | ||
| } | ||
| export function extractPayerInfoFromDerivationPath(path: string) { | ||
| return { | ||
| change: extractChangeIndexFromPath(path), | ||
| addressIndex: extractAddressIndexFromPath(path), | ||
| }; | ||
| } | ||
| /** | ||
| * @description | ||
| * Turns key format from @scure/btc-signer lib back into key origin string | ||
| * @example | ||
| * ```ts | ||
| * const [inputOne] = getPsbtTxInputs(tx); | ||
| * const keyOrigin = serializeKeyOrigin(inputOne.bip32Derivation[0][1]); | ||
| * ``` | ||
| */ | ||
| export function serializeKeyOrigin({ fingerprint, path }: BtcSignerDerivationPath) { | ||
| const values = path.map(num => (num >= HARDENED_OFFSET ? num - HARDENED_OFFSET + "'" : num)); | ||
| return `${fingerprintAsNumberToHex(fingerprint)}/${values.join('/')}`; | ||
| } | ||
| /** | ||
| * @description | ||
| * Of a given set of a `tx.input`s bip32 derivation paths from | ||
| * `@scure/btc-signer`, serialize the paths back to the string format used | ||
| * internally | ||
| */ | ||
| export function extractRequiredKeyOrigins(derivation: BtcSignerBip32Derivation[]) { | ||
| return derivation.map(([_pubkey, path]) => | ||
| serializeKeyOrigin('hashes' in path ? path.der : path) | ||
| ); | ||
| } |
| > @leather.io/bitcoin@0.37.4 build /home/runner/work/mono/mono/packages/bitcoin | ||
| > @leather.io/bitcoin@0.37.5 build /home/runner/work/mono/mono/packages/bitcoin | ||
| > tsdown | ||
@@ -10,7 +10,7 @@ | ||
| [34mℹ[39m Build start | ||
| [34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m 58.24 kB[22m [2m│ gzip: 13.65 kB[22m | ||
| [34mℹ[39m [2mdist/[22mindex.js.map [2m117.86 kB[22m [2m│ gzip: 27.60 kB[22m | ||
| [34mℹ[39m [2mdist/[22mindex.d.ts.map [2m 11.65 kB[22m [2m│ gzip: 4.75 kB[22m | ||
| [34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m 33.54 kB[22m [2m│ gzip: 6.96 kB[22m | ||
| [34mℹ[39m 4 files, total: 221.29 kB | ||
| [32m✔[39m Build complete in [32m3849ms[39m | ||
| [34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m 57.43 kB[22m [2m│ gzip: 13.44 kB[22m | ||
| [34mℹ[39m [2mdist/[22mindex.js.map [2m115.81 kB[22m [2m│ gzip: 27.07 kB[22m | ||
| [34mℹ[39m [2mdist/[22mindex.d.ts.map [2m 11.12 kB[22m [2m│ gzip: 4.51 kB[22m | ||
| [34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m 32.80 kB[22m [2m│ gzip: 6.80 kB[22m | ||
| [34mℹ[39m 4 files, total: 217.16 kB | ||
| [32m✔[39m Build complete in [32m4189ms[39m |
+5
-19
@@ -321,3 +321,3 @@ import { Bip21Options } from "bip21"; | ||
| //#endregion | ||
| //#region src/signer/bitcoin-signer.d.ts | ||
| //#region src/signer/bitcoin-payer.d.ts | ||
| type AllowedSighashTypes = ValueOf<typeof signatureHash> | SigHash; | ||
@@ -331,15 +331,5 @@ interface BitcoinAccountKeychain { | ||
| } | ||
| type WithDerivePayer<T, P> = T & { | ||
| type WithDerivePayer<T, P extends BitcoinPayer> = T & { | ||
| derivePayer(args: BitcoinPayerInfo): P; | ||
| }; | ||
| interface BitcoinSigner<Payment> { | ||
| network: BitcoinNetworkModes; | ||
| payment: Payment; | ||
| keychain: HDKey; | ||
| derivationPath: string; | ||
| address: BitcoinAddress; | ||
| publicKey: Uint8Array; | ||
| sign(tx: btc.Transaction): void; | ||
| signIndex(tx: btc.Transaction, index: number, allowedSighash?: AllowedSighashTypes[]): void; | ||
| } | ||
| interface BitcoinPayerBase { | ||
@@ -458,3 +448,2 @@ paymentType: SupportedPaymentType; | ||
| } | ||
| declare function initBitcoinAccount(derivationPath: string, policy: string): BitcoinAccount; | ||
| /** | ||
@@ -516,5 +505,2 @@ * Represents a map of `BitcoinNetworkModes` to `NetworkModes`. While Bitcoin | ||
| declare function getInputPaymentType(input: TransactionInput, network: BitcoinNetworkModes): BitcoinPaymentTypes; | ||
| declare function lookUpLedgerKeysByPath(getDerivationPath: (network: BitcoinNetworkModes, accountIndex: number) => string): (ledgerKeyMap: Record<string, { | ||
| policy: string; | ||
| } | undefined>, network: BitcoinNetworkModes) => (accountIndex: number) => BitcoinAccount | undefined; | ||
| interface GetAddressArgs { | ||
@@ -548,5 +534,5 @@ changeIndex: number; | ||
| declare function getBitcoinInputValue(input: TransactionInput): number; | ||
| declare function isNativeSegwitDerivationPath(path: string): boolean; | ||
| declare function isTaprootDerivationPath(path: string): boolean; | ||
| declare function isNativeSegwitDerivationPath(path: string): boolean; | ||
| declare function isP2TROut(signer: BitcoinSigner<P2Ret | P2TROut> | null): signer is BitcoinSigner<P2TROut>; | ||
| declare function isTaprootPayer(payer: BitcoinPayer | null): payer is BitcoinTaprootPayer; | ||
| //#endregion | ||
@@ -831,3 +817,3 @@ //#region src/payments/p2tr-address-gen.d.ts | ||
| //#endregion | ||
| export { AllowedSighashTypes, BitcoinAccount, BitcoinAccountKeychain, BitcoinError, BitcoinErrorKey, BitcoinFees, BitcoinNativeSegwitPayer, BitcoinPayer, BitcoinPayerBase, BitcoinPayerInfo, BitcoinSigner, BitcoinTaprootPayer, BtcSignerDefaultBip32Derivation, BtcSignerLibPaymentTypeIdentifers, BtcSignerNetwork, BtcSignerTapBip32Derivation, BtcSizeFeeEstimator, CalculateMaxSpendResponse, CoinSelectionOutput, CoinSelectionRecipient, DeriveAddressesFromDescriptorArgs, DeriveAddressesFromDescriptorResult, DetermineUtxosForSpendArgs, GenerateBitcoinUnsignedTransactionArgs, GetBitcoinFeesArgs, InputData, InputScriptType, MixedInputTxSizerParams, PaymentTypeMap, PsbtInput, PsbtOutput, PsbtOutputWithAddress, RawPsbt, SupportedPaymentType, SupportedPaymentTypeMap, TEST_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS, TEST_ACCOUNT_1_TAPROOT_ADDRESS, TEST_ACCOUNT_2_TAPROOT_ADDRESS, TEST_TESNET_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS, TEST_TESTNET_ACCOUNT_2_BTC_ADDRESS, TEST_TESTNET_ACCOUNT_2_TAPROOT_ADDRESS, TxSizerParams, WithDerivePayer, bip21, bip322TransactionToSignValues, bitcoinNetworkModeToCoreNetworkMode, bitcoinNetworkToCoreNetworkMap, btcAddressNetworkValidator, btcAddressValidator, btcSignerLibPaymentTypeToPaymentTypeMap, calculateMaxSpend, coinTypeMap, countInputsByScriptType, createBitcoinAddress, createNativeSegwitBitcoinJsSigner, createTaprootBitcoinJsSigner, createToSpendTx, createWalletIdDecoratedPath, decodeBitcoinTx, decodeCompressedWifPrivateKey, deconstructBtcAddress, deriveAddressIndexKeychainFromAccount, deriveAddressIndexZeroFromAccount, deriveAddressesFromDescriptor, deriveBitcoinPayerFromAccount, deriveBtcBip49SeedFromMnemonic, deriveNativeSegwitAccountFromRootKeychain, deriveNativeSegwitReceiveAddressIndexZero, deriveRootBtcKeychain, deriveTaprootAccount, deriveTaprootReceiveAddressIndexZero, determineUtxosForSpend, determineUtxosForSpendAll, ecPairFromPrivateKey, ecdsaPublicKeyLength, ecdsaPublicKeyToSchnorr, encodeMessageWitnessData, extractExtendedPublicKeyFromPolicy, extractPayerInfoFromDerivationPath, extractRequiredKeyOrigins, extractXpubFromDescriptor, filterUneconomicalUtxos, generateBitcoinUnsignedTransaction, getAddressFromOutScript, getBitcoinAddressNetworkType, getBitcoinCoinTypeIndexByNetwork, getBitcoinFees, getBitcoinInputAddress, getBitcoinInputValue, getBitcoinJsLibNetworkConfigByMode, getBitcoinTransactionFee, getBtcSignerLibNetworkConfigByMode, getDescriptorFromKeychain, getHdKeyVersionsFromNetwork, getInputPaymentType, getNativeSegwitAccountDerivationPath, getNativeSegwitAddress, getNativeSegwitAddressIndexDerivationPath, getNativeSegwitPaymentFromAddressIndex, getNetworkTypeFromAddress, getParsedInputs, getParsedOutputs, getPsbtAsTransaction, getPsbtDetails, getPsbtTotals, getPsbtTxInputs, getPsbtTxOutputs, getRawPsbt, getSizeInfo, getSpendableAmount, getTaprootAccountDerivationPath, getTaprootAddress, getTaprootAddressIndexDerivationPath, getTaprootPayment, getTaprootPaymentFromAddressIndex, getUtxoTotal, hashBip322Message, inValidCharactersAddress, inValidLengthAddress, inferNetworkFromAddress, inferNetworkFromPath, inferPaymentTypeFromAddress, inferPaymentTypeFromDescriptor, inferPaymentTypeFromPath, initBitcoinAccount, initializeBitcoinAccountKeychainFromDescriptor, invalidAddress, isBitcoinAddress, isBtcBalanceSufficient, isBtcMinimumSpend, isBtcSignerLibPaymentType, isNativeSegwitDerivationPath, isP2TROut, isSupportedMessageSigningPaymentType, isTaprootDerivationPath, isValidBitcoinAddress, isValidBitcoinNetworkAddress, legacyAddress, lookUpLedgerKeysByPath, lookupDerivationByAddress, makeNativeSegwitAccountDerivationPath, makeNativeSegwitAddressIndexDerivationPath, makePayToScriptHashAddress, makePayToScriptHashAddressBytes, makePayToScriptHashKeyHash, makeTaprootAccountDerivationPath, makeTaprootAddressIndexDerivationPath, mnemonicToRootNode, nonEmptyStringValidator, parseKnownPaymentType, payToScriptHashTestnetPrefix, payerToBip32Derivation, payerToBip32DerivationBitcoinJsLib, payerToTapBip32Derivation, payerToTapBip32DerivationBitcoinJsLib, paymentTypeMap, publicKeyToPayToScriptHashAddress, recipientAddress, segwitAddress, serializeKeyOrigin, signBip322MessageSimple, taprootAddress, toXOnly, tweakSigner, whenBitcoinNetwork, whenPaymentType, whenSupportedPaymentType }; | ||
| export { AllowedSighashTypes, BitcoinAccount, BitcoinAccountKeychain, BitcoinError, BitcoinErrorKey, BitcoinFees, BitcoinNativeSegwitPayer, BitcoinPayer, BitcoinPayerBase, BitcoinPayerInfo, BitcoinTaprootPayer, BtcSignerDefaultBip32Derivation, BtcSignerLibPaymentTypeIdentifers, BtcSignerNetwork, BtcSignerTapBip32Derivation, BtcSizeFeeEstimator, CalculateMaxSpendResponse, CoinSelectionOutput, CoinSelectionRecipient, DeriveAddressesFromDescriptorArgs, DeriveAddressesFromDescriptorResult, DetermineUtxosForSpendArgs, GenerateBitcoinUnsignedTransactionArgs, GetBitcoinFeesArgs, InputData, InputScriptType, MixedInputTxSizerParams, PaymentTypeMap, PsbtInput, PsbtOutput, PsbtOutputWithAddress, RawPsbt, SupportedPaymentType, SupportedPaymentTypeMap, TEST_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS, TEST_ACCOUNT_1_TAPROOT_ADDRESS, TEST_ACCOUNT_2_TAPROOT_ADDRESS, TEST_TESNET_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS, TEST_TESTNET_ACCOUNT_2_BTC_ADDRESS, TEST_TESTNET_ACCOUNT_2_TAPROOT_ADDRESS, TxSizerParams, WithDerivePayer, bip21, bip322TransactionToSignValues, bitcoinNetworkModeToCoreNetworkMode, bitcoinNetworkToCoreNetworkMap, btcAddressNetworkValidator, btcAddressValidator, btcSignerLibPaymentTypeToPaymentTypeMap, calculateMaxSpend, coinTypeMap, countInputsByScriptType, createBitcoinAddress, createNativeSegwitBitcoinJsSigner, createTaprootBitcoinJsSigner, createToSpendTx, createWalletIdDecoratedPath, decodeBitcoinTx, decodeCompressedWifPrivateKey, deconstructBtcAddress, deriveAddressIndexKeychainFromAccount, deriveAddressIndexZeroFromAccount, deriveAddressesFromDescriptor, deriveBitcoinPayerFromAccount, deriveBtcBip49SeedFromMnemonic, deriveNativeSegwitAccountFromRootKeychain, deriveNativeSegwitReceiveAddressIndexZero, deriveRootBtcKeychain, deriveTaprootAccount, deriveTaprootReceiveAddressIndexZero, determineUtxosForSpend, determineUtxosForSpendAll, ecPairFromPrivateKey, ecdsaPublicKeyLength, ecdsaPublicKeyToSchnorr, encodeMessageWitnessData, extractExtendedPublicKeyFromPolicy, extractPayerInfoFromDerivationPath, extractRequiredKeyOrigins, extractXpubFromDescriptor, filterUneconomicalUtxos, generateBitcoinUnsignedTransaction, getAddressFromOutScript, getBitcoinAddressNetworkType, getBitcoinCoinTypeIndexByNetwork, getBitcoinFees, getBitcoinInputAddress, getBitcoinInputValue, getBitcoinJsLibNetworkConfigByMode, getBitcoinTransactionFee, getBtcSignerLibNetworkConfigByMode, getDescriptorFromKeychain, getHdKeyVersionsFromNetwork, getInputPaymentType, getNativeSegwitAccountDerivationPath, getNativeSegwitAddress, getNativeSegwitAddressIndexDerivationPath, getNativeSegwitPaymentFromAddressIndex, getNetworkTypeFromAddress, getParsedInputs, getParsedOutputs, getPsbtAsTransaction, getPsbtDetails, getPsbtTotals, getPsbtTxInputs, getPsbtTxOutputs, getRawPsbt, getSizeInfo, getSpendableAmount, getTaprootAccountDerivationPath, getTaprootAddress, getTaprootAddressIndexDerivationPath, getTaprootPayment, getTaprootPaymentFromAddressIndex, getUtxoTotal, hashBip322Message, inValidCharactersAddress, inValidLengthAddress, inferNetworkFromAddress, inferNetworkFromPath, inferPaymentTypeFromAddress, inferPaymentTypeFromDescriptor, inferPaymentTypeFromPath, initializeBitcoinAccountKeychainFromDescriptor, invalidAddress, isBitcoinAddress, isBtcBalanceSufficient, isBtcMinimumSpend, isBtcSignerLibPaymentType, isNativeSegwitDerivationPath, isSupportedMessageSigningPaymentType, isTaprootDerivationPath, isTaprootPayer, isValidBitcoinAddress, isValidBitcoinNetworkAddress, legacyAddress, lookupDerivationByAddress, makeNativeSegwitAccountDerivationPath, makeNativeSegwitAddressIndexDerivationPath, makePayToScriptHashAddress, makePayToScriptHashAddressBytes, makePayToScriptHashKeyHash, makeTaprootAccountDerivationPath, makeTaprootAddressIndexDerivationPath, mnemonicToRootNode, nonEmptyStringValidator, parseKnownPaymentType, payToScriptHashTestnetPrefix, payerToBip32Derivation, payerToBip32DerivationBitcoinJsLib, payerToTapBip32Derivation, payerToTapBip32DerivationBitcoinJsLib, paymentTypeMap, publicKeyToPayToScriptHashAddress, recipientAddress, segwitAddress, serializeKeyOrigin, signBip322MessageSimple, taprootAddress, toXOnly, tweakSigner, whenBitcoinNetwork, whenPaymentType, whenSupportedPaymentType }; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","names":[],"sources":["../src/bip21/bip21.ts","../src/bip322/bip322-utils.ts","../src/bip322/sign-message-bip322-bitcoinjs.ts","../src/coin-selection/coin-selection.ts","../src/coin-selection/coin-selection.utils.ts","../src/coin-selection/calculate-max-spend.ts","../src/fees/bitcoin-fees.ts","../src/fees/btc-size-fee-estimator.ts","../src/mocks/mocks.ts","../src/schemas/address-schema.ts","../src/signer/bitcoin-signer.ts","../src/utils/bitcoin.network.ts","../src/utils/bitcoin.utils.ts","../src/payments/p2tr-address-gen.ts","../src/payments/p2wpkh-address-gen.ts","../src/payments/p2wsh-p2sh-address-gen.ts","../src/psbt/psbt-inputs.ts","../src/psbt/psbt-outputs.ts","../src/psbt/psbt-totals.ts","../src/psbt/psbt-details.ts","../src/psbt/utils.ts","../src/transactions/generate-unsigned-transaction.ts","../src/validation/address-validation.ts","../src/validation/amount-validation.ts","../src/validation/bitcoin-address.ts","../src/validation/bitcoin-error.ts","../src/utils/bitcoin.descriptors.ts","../src/utils/lookup-derivation-by-address.ts","../src/utils/deconstruct-btc-address.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;UAIU,gBAAA;;;;KAKL,WAAA;;QAGO;;;;;cAOC;+CACgC;qCAcR;;;;iBCjBrB,oBAAA,MAA0B,aAAU,OAAA,CAAA;iBAWpC,iBAAA,UAA2B,sBAAmB,WAAA;cAMjD;eAIZ,WAAA;;;;iBAQe,oCAAA;;;;;iBAQA,wBAAA,eAAuC,WAAQ,OAAA;iBAS/C,WAAA,SAAoB,OAAA,CAAQ,qBAAyB,OAAA,CAAQ;;;iBChD7D,iCAAA,aAA8C,SAAM,OAAA,CAAA;iBAIpD,4BAAA,aAAyC,SAAM,OAAA,CAAA;iBAI/C,eAAA,UACL,0CAEA;;;;UAsCD,uBAAA;WACC;;WAEA;iBACM,OAAA,CAAQ,OAAO,QAAQ,GAAA,CAAI;;iBAEtB,uBAAA,OAA8B,0BAAuB;;;EFlEjE,YAAA,QAAgB,YAAA,CAAA;EAKrB,SAAA,EAAA,MAAW;AAUhB,CAAA,CAAA;;;UGJiB,mBAAA;;;;UAKA,sBAAA;;UAEP;;UAGO;;cAEH;SACL;;iBAEO,oCAAoC;;;;GAIjD,2BAA2B;;;IH9BpB,KAAA,EAAA,MAAA;IAKL,OAAA,EAAA,MAAW;EAUH,CAAA,EAAA;;;;ACFG,iBE+CA,sBF/C0B,CAAA,UE+CO,SF/CG,CAAA,CAAA;EAAA,OAAA;EAAA,UAAA;EAAA;AAAA,CAAA,EEmDjD,0BFnDiD,CEmDtB,CFnDsB,CAAA,CAAA,EAAA;EAWpC,QAAA,EAAA,MAAA;EAA2B,OAAA,EAAA,MAAA;EAAmB,QAAA,EAAA,MAAA;EAAA,aAAA,GAAA,EAAA;EAAA,MAAA,GAAA,EAAA;EAMjD,OAAA,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A;iBAQA,4BAAA,2BAAuD;;;UClB7D,4BAAA;gBACM;YACJ;;iBAEI,sBAAA;;;GAAmD;iBAInD,iBAAA,eAAgC;;;iBCNhC,gBAAA,0BAA0C;iBAU1C,oBAAA,iBAAqC;;;cCbxC,YAAA,SAAqB,KAAA;WAChB;uBACK;;KAUX,eAAA,GACR;;;iBCDY;;;oBACG;iBAYH,8BAAA,sBAAoD;iBAYpD,yBAAA;UAQC,iCAAA;;WAEN;;;UAIM,mCAAA;;;;iBAKD,6BAAA;;;;GAIb,oCAAoC;;;UC/C7B,6BAAA;;;;;iBAKM,yBAAA,OAAgC,0CAM7B;;;;;;;;;;;iBCvBH,qBAAA;;aAAqB,WAAA"} | ||
| {"version":3,"file":"index.d.ts","names":[],"sources":["../src/bip21/bip21.ts","../src/bip322/bip322-utils.ts","../src/bip322/sign-message-bip322-bitcoinjs.ts","../src/coin-selection/coin-selection.ts","../src/coin-selection/coin-selection.utils.ts","../src/coin-selection/calculate-max-spend.ts","../src/fees/bitcoin-fees.ts","../src/fees/btc-size-fee-estimator.ts","../src/mocks/mocks.ts","../src/schemas/address-schema.ts","../src/signer/bitcoin-payer.ts","../src/utils/bitcoin.network.ts","../src/utils/bitcoin.utils.ts","../src/payments/p2tr-address-gen.ts","../src/payments/p2wpkh-address-gen.ts","../src/payments/p2wsh-p2sh-address-gen.ts","../src/psbt/psbt-inputs.ts","../src/psbt/psbt-outputs.ts","../src/psbt/psbt-totals.ts","../src/psbt/psbt-details.ts","../src/psbt/utils.ts","../src/transactions/generate-unsigned-transaction.ts","../src/validation/address-validation.ts","../src/validation/amount-validation.ts","../src/validation/bitcoin-address.ts","../src/validation/bitcoin-error.ts","../src/utils/bitcoin.descriptors.ts","../src/utils/lookup-derivation-by-address.ts","../src/utils/deconstruct-btc-address.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;UAIU,gBAAA;;;;KAKL,WAAA;;QAGO;;;;;cAOC;+CACgC;qCAcR;;;;iBCjBrB,oBA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BAK9C,UAAA,gBAA0B,aAAa,kBAAkB,SAAA,CAAU;;;UCIlE;;;WAGN;cACG;SACL;;kCAEyB,2BAA2B;;iBAE7C,6CACJ;;;;;;;;;;;GAST,uCAAuC;ErBhChC,EAAA,iBAAgB;EAKrB,GAAA,EAAA,MAAA;EAUQ,IAAA,YAsBZ,gBAPoC,CAAA;;;;;;iBsB5BrB,4BAAA,UAAsC,sBAAsB;iBAO5D,qBAAA;iBAQA,4BAAA,2BAAuD;;;UClB7D,4BAAA;gBACM;YACJ;;iBAEI,sBAAA;;;GAAmD;iBAInD,iBAAA,eAAgC;;;iBCNhC,gBAAA,0BAA0C;iBAU1C,oBAAA,iBAAqC;;;cCbxC,YAAA,SAAqB,KAAA;WAChB;uBACK;;KAUX,eAAA,GACR;;;iBCDY;;;oBACG;iBAYH,8BAAA,sBAAoD;iBAYpD,yBAAA;UAQC,iCAAA;;WAEN;;;UAIM,mCAAA;;;;iBAKD,6BAAA;;;;GAIb,oCAAoC;;;UC/C7B,6BAAA;;;;;iBAKM,yBAAA,OAAgC,0CAM7B;;;;;;;;;;;iBCvBH,qBAAA;;aAAqB,WAAA"} |
+9
-28
| import { decode, encode } from "bip21"; | ||
| import { assertUnreachable, createCounter, createMoney, defaultWalletKeyId, hexToNumber, isDefined, isEmptyString, isError, isString, isUndefined, satToBtc, subtractMoney, sumMoney, sumNumbers, whenNetwork } from "@leather.io/utils"; | ||
| import { assertUnreachable, createCounter, createMoney, hexToNumber, isDefined, isEmptyString, isError, isString, isUndefined, satToBtc, subtractMoney, sumMoney, sumNumbers, whenNetwork } from "@leather.io/utils"; | ||
| import ecc from "@bitcoinerlab/secp256k1"; | ||
@@ -12,3 +12,3 @@ import { sha256 } from "@noble/hashes/sha256"; | ||
| import * as btc from "@scure/btc-signer"; | ||
| import { DerivationPathDepth, appendAddressIndexToPath, decomposeDescriptor, deriveBip39SeedFromMnemonic, deriveKeychainFromXpub, deriveRootBip32Keychain, extractAccountIndexFromPath, extractAddressIndexFromPath, extractChangeIndexFromPath, extractPurposeFromPath, fingerprintAsNumberToHex, keyOriginToDerivationPath } from "@leather.io/crypto"; | ||
| import { DerivationPathDepth, appendAddressIndexToPath, decomposeDescriptor, deriveBip39SeedFromMnemonic, deriveKeychainFromXpub, deriveRootBip32Keychain, extractAddressIndexFromPath, extractChangeIndexFromPath, extractPurposeFromPath, fingerprintAsNumberToHex, keyOriginToDerivationPath } from "@leather.io/crypto"; | ||
| import validate$1, { AddressType, Network, getAddressInfo, validate } from "bitcoin-address-validation"; | ||
@@ -204,13 +204,2 @@ import { base58check, base64 } from "@scure/base"; | ||
| //#region src/utils/bitcoin.utils.ts | ||
| function initBitcoinAccount(derivationPath, policy) { | ||
| const xpub = extractExtendedPublicKeyFromPolicy(policy); | ||
| const network = inferNetworkFromPath(derivationPath); | ||
| return { | ||
| keychain: HDKey.fromExtendedKey(xpub, getHdKeyVersionsFromNetwork(network)), | ||
| network, | ||
| derivationPath, | ||
| type: inferPaymentTypeFromPath(derivationPath), | ||
| accountIndex: extractAccountIndexFromPath(derivationPath) | ||
| }; | ||
| } | ||
| /** | ||
@@ -357,10 +346,2 @@ * Represents a map of `BitcoinNetworkModes` to `NetworkModes`. While Bitcoin | ||
| } | ||
| function lookUpLedgerKeysByPath(getDerivationPath) { | ||
| return (ledgerKeyMap, network) => (accountIndex) => { | ||
| const path = getDerivationPath(network, accountIndex); | ||
| const account = ledgerKeyMap[path.replace("m", defaultWalletKeyId)]; | ||
| if (!account) return; | ||
| return initBitcoinAccount(path, account.policy); | ||
| }; | ||
| } | ||
| function getTaprootAddress({ changeIndex, addressIndex, keychain, network }) { | ||
@@ -430,11 +411,11 @@ if (!keychain) throw new Error("Expected keychain to be provided"); | ||
| } | ||
| function isNativeSegwitDerivationPath(path) { | ||
| return extractPurposeFromPath(path) === 84; | ||
| } | ||
| function isTaprootDerivationPath(path) { | ||
| return extractPurposeFromPath(path) === 86; | ||
| } | ||
| function isNativeSegwitDerivationPath(path) { | ||
| return extractPurposeFromPath(path) === 84; | ||
| function isTaprootPayer(payer) { | ||
| return !!payer && isTaprootDerivationPath(payer.keyOrigin); | ||
| } | ||
| function isP2TROut(signer) { | ||
| return !!signer && isTaprootDerivationPath(signer.derivationPath); | ||
| } | ||
@@ -1173,3 +1154,3 @@ //#endregion | ||
| //#endregion | ||
| //#region src/signer/bitcoin-signer.ts | ||
| //#region src/signer/bitcoin-payer.ts | ||
| function initializeBitcoinAccountKeychainFromDescriptor(descriptor) { | ||
@@ -1488,3 +1469,3 @@ const { fingerprint, keyOrigin } = decomposeDescriptor(descriptor); | ||
| //#endregion | ||
| export { BitcoinError, BtcSizeFeeEstimator, TEST_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS, TEST_ACCOUNT_1_TAPROOT_ADDRESS, TEST_ACCOUNT_2_TAPROOT_ADDRESS, TEST_TESNET_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS, TEST_TESTNET_ACCOUNT_2_BTC_ADDRESS, TEST_TESTNET_ACCOUNT_2_TAPROOT_ADDRESS, bip21, bip322TransactionToSignValues, bitcoinNetworkModeToCoreNetworkMode, bitcoinNetworkToCoreNetworkMap, btcAddressNetworkValidator, btcAddressValidator, btcSignerLibPaymentTypeToPaymentTypeMap, calculateMaxSpend, coinTypeMap, countInputsByScriptType, createBitcoinAddress, createNativeSegwitBitcoinJsSigner, createTaprootBitcoinJsSigner, createToSpendTx, createWalletIdDecoratedPath, decodeBitcoinTx, decodeCompressedWifPrivateKey, deconstructBtcAddress, deriveAddressIndexKeychainFromAccount, deriveAddressIndexZeroFromAccount, deriveAddressesFromDescriptor, deriveBitcoinPayerFromAccount, deriveBtcBip49SeedFromMnemonic, deriveNativeSegwitAccountFromRootKeychain, deriveNativeSegwitReceiveAddressIndexZero, deriveRootBtcKeychain, deriveTaprootAccount, deriveTaprootReceiveAddressIndexZero, determineUtxosForSpend, determineUtxosForSpendAll, ecPairFromPrivateKey, ecdsaPublicKeyLength, ecdsaPublicKeyToSchnorr, encodeMessageWitnessData, extractExtendedPublicKeyFromPolicy, extractPayerInfoFromDerivationPath, extractRequiredKeyOrigins, extractXpubFromDescriptor, filterUneconomicalUtxos, generateBitcoinUnsignedTransaction, getAddressFromOutScript, getBitcoinAddressNetworkType, getBitcoinCoinTypeIndexByNetwork, getBitcoinFees, getBitcoinInputAddress, getBitcoinInputValue, getBitcoinJsLibNetworkConfigByMode, getBitcoinTransactionFee, getBtcSignerLibNetworkConfigByMode, getDescriptorFromKeychain, getHdKeyVersionsFromNetwork, getInputPaymentType, getNativeSegwitAccountDerivationPath, getNativeSegwitAddress, getNativeSegwitAddressIndexDerivationPath, getNativeSegwitPaymentFromAddressIndex, getNetworkTypeFromAddress, getParsedInputs, getParsedOutputs, getPsbtAsTransaction, getPsbtDetails, getPsbtTotals, getPsbtTxInputs, getPsbtTxOutputs, getRawPsbt, getSizeInfo, getSpendableAmount, getTaprootAccountDerivationPath, getTaprootAddress, getTaprootAddressIndexDerivationPath, getTaprootPayment, getTaprootPaymentFromAddressIndex, getUtxoTotal, hashBip322Message, inValidCharactersAddress, inValidLengthAddress, inferNetworkFromAddress, inferNetworkFromPath, inferPaymentTypeFromAddress, inferPaymentTypeFromDescriptor, inferPaymentTypeFromPath, initBitcoinAccount, initializeBitcoinAccountKeychainFromDescriptor, invalidAddress, isBitcoinAddress, isBtcBalanceSufficient, isBtcMinimumSpend, isBtcSignerLibPaymentType, isNativeSegwitDerivationPath, isP2TROut, isSupportedMessageSigningPaymentType, isTaprootDerivationPath, isValidBitcoinAddress, isValidBitcoinNetworkAddress, legacyAddress, lookUpLedgerKeysByPath, lookupDerivationByAddress, makeNativeSegwitAccountDerivationPath, makeNativeSegwitAddressIndexDerivationPath, makePayToScriptHashAddress, makePayToScriptHashAddressBytes, makePayToScriptHashKeyHash, makeTaprootAccountDerivationPath, makeTaprootAddressIndexDerivationPath, mnemonicToRootNode, nonEmptyStringValidator, parseKnownPaymentType, payToScriptHashTestnetPrefix, payerToBip32Derivation, payerToBip32DerivationBitcoinJsLib, payerToTapBip32Derivation, payerToTapBip32DerivationBitcoinJsLib, paymentTypeMap, publicKeyToPayToScriptHashAddress, recipientAddress, segwitAddress, serializeKeyOrigin, signBip322MessageSimple, taprootAddress, toXOnly, tweakSigner, whenBitcoinNetwork, whenPaymentType, whenSupportedPaymentType }; | ||
| export { BitcoinError, BtcSizeFeeEstimator, TEST_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS, TEST_ACCOUNT_1_TAPROOT_ADDRESS, TEST_ACCOUNT_2_TAPROOT_ADDRESS, TEST_TESNET_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS, TEST_TESTNET_ACCOUNT_2_BTC_ADDRESS, TEST_TESTNET_ACCOUNT_2_TAPROOT_ADDRESS, bip21, bip322TransactionToSignValues, bitcoinNetworkModeToCoreNetworkMode, bitcoinNetworkToCoreNetworkMap, btcAddressNetworkValidator, btcAddressValidator, btcSignerLibPaymentTypeToPaymentTypeMap, calculateMaxSpend, coinTypeMap, countInputsByScriptType, createBitcoinAddress, createNativeSegwitBitcoinJsSigner, createTaprootBitcoinJsSigner, createToSpendTx, createWalletIdDecoratedPath, decodeBitcoinTx, decodeCompressedWifPrivateKey, deconstructBtcAddress, deriveAddressIndexKeychainFromAccount, deriveAddressIndexZeroFromAccount, deriveAddressesFromDescriptor, deriveBitcoinPayerFromAccount, deriveBtcBip49SeedFromMnemonic, deriveNativeSegwitAccountFromRootKeychain, deriveNativeSegwitReceiveAddressIndexZero, deriveRootBtcKeychain, deriveTaprootAccount, deriveTaprootReceiveAddressIndexZero, determineUtxosForSpend, determineUtxosForSpendAll, ecPairFromPrivateKey, ecdsaPublicKeyLength, ecdsaPublicKeyToSchnorr, encodeMessageWitnessData, extractExtendedPublicKeyFromPolicy, extractPayerInfoFromDerivationPath, extractRequiredKeyOrigins, extractXpubFromDescriptor, filterUneconomicalUtxos, generateBitcoinUnsignedTransaction, getAddressFromOutScript, getBitcoinAddressNetworkType, getBitcoinCoinTypeIndexByNetwork, getBitcoinFees, getBitcoinInputAddress, getBitcoinInputValue, getBitcoinJsLibNetworkConfigByMode, getBitcoinTransactionFee, getBtcSignerLibNetworkConfigByMode, getDescriptorFromKeychain, getHdKeyVersionsFromNetwork, getInputPaymentType, getNativeSegwitAccountDerivationPath, getNativeSegwitAddress, getNativeSegwitAddressIndexDerivationPath, getNativeSegwitPaymentFromAddressIndex, getNetworkTypeFromAddress, getParsedInputs, getParsedOutputs, getPsbtAsTransaction, getPsbtDetails, getPsbtTotals, getPsbtTxInputs, getPsbtTxOutputs, getRawPsbt, getSizeInfo, getSpendableAmount, getTaprootAccountDerivationPath, getTaprootAddress, getTaprootAddressIndexDerivationPath, getTaprootPayment, getTaprootPaymentFromAddressIndex, getUtxoTotal, hashBip322Message, inValidCharactersAddress, inValidLengthAddress, inferNetworkFromAddress, inferNetworkFromPath, inferPaymentTypeFromAddress, inferPaymentTypeFromDescriptor, inferPaymentTypeFromPath, initializeBitcoinAccountKeychainFromDescriptor, invalidAddress, isBitcoinAddress, isBtcBalanceSufficient, isBtcMinimumSpend, isBtcSignerLibPaymentType, isNativeSegwitDerivationPath, isSupportedMessageSigningPaymentType, isTaprootDerivationPath, isTaprootPayer, isValidBitcoinAddress, isValidBitcoinNetworkAddress, legacyAddress, lookupDerivationByAddress, makeNativeSegwitAccountDerivationPath, makeNativeSegwitAddressIndexDerivationPath, makePayToScriptHashAddress, makePayToScriptHashAddressBytes, makePayToScriptHashKeyHash, makeTaprootAccountDerivationPath, makeTaprootAddressIndexDerivationPath, mnemonicToRootNode, nonEmptyStringValidator, parseKnownPaymentType, payToScriptHashTestnetPrefix, payerToBip32Derivation, payerToBip32DerivationBitcoinJsLib, payerToTapBip32Derivation, payerToTapBip32DerivationBitcoinJsLib, paymentTypeMap, publicKeyToPayToScriptHashAddress, recipientAddress, segwitAddress, serializeKeyOrigin, signBip322MessageSimple, taprootAddress, toXOnly, tweakSigner, whenBitcoinNetwork, whenPaymentType, whenSupportedPaymentType }; | ||
| //# sourceMappingURL=index.js.map |
+6
-6
@@ -5,3 +5,3 @@ { | ||
| "description": "Shared bitcoin utilities", | ||
| "version": "0.37.4", | ||
| "version": "0.37.5", | ||
| "license": "MIT", | ||
@@ -36,6 +36,6 @@ "homepage": "https://github.com/leather.io/mono/tree/dev/packages/bitcoin", | ||
| "zod": "4.0.17", | ||
| "@leather.io/constants": "0.35.0", | ||
| "@leather.io/crypto": "1.12.21", | ||
| "@leather.io/models": "0.55.0", | ||
| "@leather.io/utils": "0.51.2" | ||
| "@leather.io/crypto": "1.12.22", | ||
| "@leather.io/constants": "0.35.1", | ||
| "@leather.io/models": "0.56.0", | ||
| "@leather.io/utils": "0.51.3" | ||
| }, | ||
@@ -49,3 +49,3 @@ "devDependencies": { | ||
| "@leather.io/prettier-config": "0.9.0", | ||
| "@leather.io/rpc": "2.21.15", | ||
| "@leather.io/rpc": "2.21.16", | ||
| "@leather.io/test-config": "0.1.3", | ||
@@ -52,0 +52,0 @@ "@leather.io/tsconfig-config": "0.11.1" |
+1
-1
@@ -26,3 +26,3 @@ export * from './bip21/bip21'; | ||
| export * from './signer/bitcoin-signer'; | ||
| export * from './signer/bitcoin-payer'; | ||
@@ -29,0 +29,0 @@ export * from './transactions/generate-unsigned-transaction'; |
@@ -1,2 +0,2 @@ | ||
| import { serializeKeyOrigin } from './bitcoin-signer'; | ||
| import { serializeKeyOrigin } from './bitcoin-payer'; | ||
@@ -3,0 +3,0 @@ describe(serializeKeyOrigin.name, () => { |
@@ -14,3 +14,3 @@ import * as btc from '@scure/btc-signer'; | ||
| payerToTapBip32Derivation, | ||
| } from '../signer/bitcoin-signer'; | ||
| } from '../signer/bitcoin-payer'; | ||
| import { BtcSignerNetwork } from '../utils/bitcoin.network'; | ||
@@ -17,0 +17,0 @@ import { BitcoinError } from '../validation/bitcoin-error'; |
@@ -5,14 +5,9 @@ import { hexToBytes } from '@noble/hashes/utils'; | ||
| import * as btc from '@scure/btc-signer'; | ||
| import type { P2Ret, P2TROut } from '@scure/btc-signer/payment'; | ||
| import { TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt'; | ||
| import type { BitcoinSigner } from 'signer/bitcoin-signer'; | ||
| import type { BitcoinPayer, BitcoinTaprootPayer } from 'signer/bitcoin-payer'; | ||
| import { | ||
| DerivationPathDepth, | ||
| extractAccountIndexFromPath, | ||
| extractPurposeFromPath, | ||
| } from '@leather.io/crypto'; | ||
| import { DerivationPathDepth, extractPurposeFromPath } from '@leather.io/crypto'; | ||
| import { BitcoinAddress, BitcoinNetworkModes, NetworkModes } from '@leather.io/models'; | ||
| import type { BitcoinPaymentTypes } from '@leather.io/rpc'; | ||
| import { defaultWalletKeyId, isDefined, whenNetwork } from '@leather.io/utils'; | ||
| import { isDefined, whenNetwork } from '@leather.io/utils'; | ||
@@ -31,13 +26,2 @@ import { getTaprootPayment } from '../payments/p2tr-address-gen'; | ||
| } | ||
| export function initBitcoinAccount(derivationPath: string, policy: string): BitcoinAccount { | ||
| const xpub = extractExtendedPublicKeyFromPolicy(policy); | ||
| const network = inferNetworkFromPath(derivationPath); | ||
| return { | ||
| keychain: HDKey.fromExtendedKey(xpub, getHdKeyVersionsFromNetwork(network)), | ||
| network, | ||
| derivationPath, | ||
| type: inferPaymentTypeFromPath(derivationPath), | ||
| accountIndex: extractAccountIndexFromPath(derivationPath), | ||
| }; | ||
| } | ||
@@ -260,20 +244,2 @@ /** | ||
| // Ledger wallets are keyed by their derivation path. To reuse the look up logic | ||
| // between payment types, this factory fn accepts a fn that generates the path | ||
| export function lookUpLedgerKeysByPath( | ||
| getDerivationPath: (network: BitcoinNetworkModes, accountIndex: number) => string | ||
| ) { | ||
| return ( | ||
| ledgerKeyMap: Record<string, { policy: string } | undefined>, | ||
| network: BitcoinNetworkModes | ||
| ) => | ||
| (accountIndex: number) => { | ||
| const path = getDerivationPath(network, accountIndex); | ||
| // Single wallet mode, hardcoded default walletId | ||
| const account = ledgerKeyMap[path.replace('m', defaultWalletKeyId)]; | ||
| if (!account) return; | ||
| return initBitcoinAccount(path, account.policy); | ||
| }; | ||
| } | ||
| interface GetAddressArgs { | ||
@@ -389,2 +355,6 @@ changeIndex: number; | ||
| export function isNativeSegwitDerivationPath(path: string) { | ||
| return extractPurposeFromPath(path) === 84; | ||
| } | ||
| export function isTaprootDerivationPath(path: string) { | ||
@@ -394,10 +364,4 @@ return extractPurposeFromPath(path) === 86; | ||
| export function isNativeSegwitDerivationPath(path: string) { | ||
| return extractPurposeFromPath(path) === 84; | ||
| export function isTaprootPayer(payer: BitcoinPayer | null): payer is BitcoinTaprootPayer { | ||
| return !!payer && isTaprootDerivationPath(payer.keyOrigin); | ||
| } | ||
| export function isP2TROut( | ||
| signer: BitcoinSigner<P2Ret | P2TROut> | null | ||
| ): signer is BitcoinSigner<P2TROut> { | ||
| return !!signer && isTaprootDerivationPath(signer.derivationPath); | ||
| } |
| import { HARDENED_OFFSET, HDKey } from '@scure/bip32'; | ||
| import * as btc from '@scure/btc-signer'; | ||
| import { P2Ret, P2TROut } from '@scure/btc-signer/payment'; | ||
| import { SigHash } from '@scure/btc-signer/transaction'; | ||
| import * as bitcoin from 'bitcoinjs-lib'; | ||
| import { | ||
| DerivationPathDepth, | ||
| appendAddressIndexToPath, | ||
| decomposeDescriptor, | ||
| deriveKeychainFromXpub, | ||
| extractAddressIndexFromPath, | ||
| extractChangeIndexFromPath, | ||
| fingerprintAsNumberToHex, | ||
| keyOriginToDerivationPath, | ||
| } from '@leather.io/crypto'; | ||
| import type { BitcoinAddress, BitcoinNetworkModes, ValueOf } from '@leather.io/models'; | ||
| import { signatureHash } from '@leather.io/rpc'; | ||
| import { hexToNumber } from '@leather.io/utils'; | ||
| import { getTaprootPaymentFromAddressIndex } from '../payments/p2tr-address-gen'; | ||
| import { getNativeSegwitPaymentFromAddressIndex } from '../payments/p2wpkh-address-gen'; | ||
| import { | ||
| SupportedPaymentType, | ||
| ecdsaPublicKeyToSchnorr, | ||
| extractExtendedPublicKeyFromPolicy, | ||
| inferPaymentTypeFromPath, | ||
| whenSupportedPaymentType, | ||
| } from '../utils/bitcoin.utils'; | ||
| export type AllowedSighashTypes = ValueOf<typeof signatureHash> | SigHash; | ||
| export interface BitcoinAccountKeychain { | ||
| descriptor: string; | ||
| masterKeyFingerprint: string; | ||
| keyOrigin: string; | ||
| keychain: HDKey; | ||
| xpub: string; | ||
| } | ||
| export type WithDerivePayer<T, P> = T & { derivePayer(args: BitcoinPayerInfo): P }; | ||
| export interface BitcoinSigner<Payment> { | ||
| network: BitcoinNetworkModes; | ||
| payment: Payment; | ||
| keychain: HDKey; | ||
| derivationPath: string; | ||
| address: BitcoinAddress; | ||
| publicKey: Uint8Array; | ||
| sign(tx: btc.Transaction): void; | ||
| signIndex(tx: btc.Transaction, index: number, allowedSighash?: AllowedSighashTypes[]): void; | ||
| } | ||
| export interface BitcoinPayerBase { | ||
| paymentType: SupportedPaymentType; | ||
| network: BitcoinNetworkModes; | ||
| address: BitcoinAddress; | ||
| keyOrigin: string; | ||
| masterKeyFingerprint: string; | ||
| publicKey: Uint8Array; | ||
| } | ||
| export interface BitcoinNativeSegwitPayer extends BitcoinPayerBase { | ||
| paymentType: 'p2wpkh'; | ||
| payment: P2Ret; | ||
| } | ||
| export interface BitcoinTaprootPayer extends BitcoinPayerBase { | ||
| paymentType: 'p2tr'; | ||
| payment: P2TROut; | ||
| } | ||
| export type BitcoinPayer = BitcoinNativeSegwitPayer | BitcoinTaprootPayer; | ||
| export function initializeBitcoinAccountKeychainFromDescriptor( | ||
| descriptor: string | ||
| ): BitcoinAccountKeychain { | ||
| const { fingerprint, keyOrigin } = decomposeDescriptor(descriptor); | ||
| return { | ||
| descriptor, | ||
| xpub: extractExtendedPublicKeyFromPolicy(descriptor), | ||
| keyOrigin, | ||
| masterKeyFingerprint: fingerprint, | ||
| keychain: deriveKeychainFromXpub(extractExtendedPublicKeyFromPolicy(descriptor)), | ||
| }; | ||
| } | ||
| export interface BitcoinPayerInfo { | ||
| change: number; | ||
| addressIndex: number; | ||
| } | ||
| export function deriveBitcoinPayerFromAccount(descriptor: string, network: BitcoinNetworkModes) { | ||
| const { fingerprint, keyOrigin } = decomposeDescriptor(descriptor); | ||
| const accountKeychain = deriveKeychainFromXpub(extractExtendedPublicKeyFromPolicy(descriptor)); | ||
| const paymentType = inferPaymentTypeFromPath(keyOrigin) as SupportedPaymentType; | ||
| if (accountKeychain.depth !== DerivationPathDepth.Account) | ||
| throw new Error('Keychain passed is not an account'); | ||
| return ({ change, addressIndex }: BitcoinPayerInfo) => { | ||
| const childKeychain = accountKeychain.deriveChild(change).deriveChild(addressIndex); | ||
| const derivePayerFromAccount = whenSupportedPaymentType(paymentType)({ | ||
| p2tr: getTaprootPaymentFromAddressIndex, | ||
| p2wpkh: getNativeSegwitPaymentFromAddressIndex, | ||
| }); | ||
| const payment = derivePayerFromAccount(childKeychain, network); | ||
| return { | ||
| keyOrigin: appendAddressIndexToPath(keyOrigin, change, addressIndex), | ||
| masterKeyFingerprint: fingerprint, | ||
| paymentType, | ||
| network, | ||
| payment, | ||
| get address() { | ||
| if (!payment.address) throw new Error('Payment address could not be derived'); | ||
| return payment.address; | ||
| }, | ||
| get publicKey() { | ||
| if (!childKeychain.publicKey) throw new Error('Public key could not be derived'); | ||
| return childKeychain.publicKey; | ||
| }, | ||
| }; | ||
| }; | ||
| } | ||
| interface BtcSignerDerivationPath { | ||
| fingerprint: number; | ||
| path: number[]; | ||
| } | ||
| export type BtcSignerDefaultBip32Derivation = [Uint8Array, BtcSignerDerivationPath]; | ||
| export type BtcSignerTapBip32Derivation = [ | ||
| Uint8Array, | ||
| { hashes: Uint8Array[]; der: BtcSignerDerivationPath }, | ||
| ]; | ||
| type BtcSignerBip32Derivation = BtcSignerDefaultBip32Derivation | BtcSignerTapBip32Derivation; | ||
| type PayerToBip32DerivationArgs = Pick< | ||
| BitcoinPayer, | ||
| 'masterKeyFingerprint' | 'keyOrigin' | 'publicKey' | ||
| >; | ||
| /** | ||
| * @example | ||
| * ```ts | ||
| * tx.addInput({ | ||
| * ...input, | ||
| * bip32Derivation: [payerToBip32Derivation(payer)], | ||
| * }) | ||
| * ``` | ||
| */ | ||
| export function payerToBip32Derivation( | ||
| args: PayerToBip32DerivationArgs | ||
| ): BtcSignerDefaultBip32Derivation { | ||
| return [ | ||
| args.publicKey, | ||
| { | ||
| fingerprint: hexToNumber(args.masterKeyFingerprint), | ||
| path: btc.bip32Path(keyOriginToDerivationPath(args.keyOrigin)), | ||
| }, | ||
| ]; | ||
| } | ||
| /** | ||
| * @example | ||
| * ```ts | ||
| * tx.addInput({ | ||
| * ...input, | ||
| * tapBip32Derivation: [payerToTapBip32Derivation(payer)], | ||
| * }) | ||
| * ``` | ||
| */ | ||
| export function payerToTapBip32Derivation( | ||
| args: PayerToBip32DerivationArgs | ||
| ): BtcSignerTapBip32Derivation { | ||
| return [ | ||
| // TODO: @kyranjamie to default to schnoor when TR so conversion isn't | ||
| // necessary here? | ||
| ecdsaPublicKeyToSchnorr(args.publicKey), | ||
| { | ||
| hashes: [], | ||
| der: { | ||
| fingerprint: hexToNumber(args.masterKeyFingerprint), | ||
| path: btc.bip32Path(keyOriginToDerivationPath(args.keyOrigin)), | ||
| }, | ||
| }, | ||
| ]; | ||
| } | ||
| type PsbtInputBitcoinJsLib = bitcoin.Psbt['data']['inputs']['0']; | ||
| type TapBip32DerivationBitcoinJsLib = NonNullable<PsbtInputBitcoinJsLib['tapBip32Derivation']>['0']; | ||
| export function payerToTapBip32DerivationBitcoinJsLib( | ||
| args: PayerToBip32DerivationArgs | ||
| ): TapBip32DerivationBitcoinJsLib { | ||
| return { | ||
| masterFingerprint: Buffer.from(args.masterKeyFingerprint, 'hex'), | ||
| path: keyOriginToDerivationPath(args.keyOrigin), | ||
| leafHashes: [], | ||
| pubkey: Buffer.from(ecdsaPublicKeyToSchnorr(args.publicKey)), | ||
| }; | ||
| } | ||
| type Bip32DerivationBitcoinJsLib = NonNullable<PsbtInputBitcoinJsLib['bip32Derivation']>['0']; | ||
| export function payerToBip32DerivationBitcoinJsLib( | ||
| args: PayerToBip32DerivationArgs | ||
| ): Bip32DerivationBitcoinJsLib { | ||
| return { | ||
| masterFingerprint: Buffer.from(args.masterKeyFingerprint, 'hex'), | ||
| path: keyOriginToDerivationPath(args.keyOrigin), | ||
| pubkey: Buffer.from(args.publicKey), | ||
| }; | ||
| } | ||
| export function extractPayerInfoFromDerivationPath(path: string) { | ||
| return { | ||
| change: extractChangeIndexFromPath(path), | ||
| addressIndex: extractAddressIndexFromPath(path), | ||
| }; | ||
| } | ||
| /** | ||
| * @description | ||
| * Turns key format from @scure/btc-signer lib back into key origin string | ||
| * @example | ||
| * ```ts | ||
| * const [inputOne] = getPsbtTxInputs(tx); | ||
| * const keyOrigin = serializeKeyOrigin(inputOne.bip32Derivation[0][1]); | ||
| * ``` | ||
| */ | ||
| export function serializeKeyOrigin({ fingerprint, path }: BtcSignerDerivationPath) { | ||
| const values = path.map(num => (num >= HARDENED_OFFSET ? num - HARDENED_OFFSET + "'" : num)); | ||
| return `${fingerprintAsNumberToHex(fingerprint)}/${values.join('/')}`; | ||
| } | ||
| /** | ||
| * @description | ||
| * Of a given set of a `tx.input`s bip32 derivation paths from | ||
| * `@scure/btc-signer`, serialize the paths back to the string format used | ||
| * internally | ||
| */ | ||
| export function extractRequiredKeyOrigins(derivation: BtcSignerBip32Derivation[]) { | ||
| return derivation.map(([_pubkey, path]) => | ||
| serializeKeyOrigin('hashes' in path ? path.der : path) | ||
| ); | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
486094
-1.08%7334
-1.04%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated