@swapkit/toolboxes 6.4.0 → 6.5.0

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/chunk-2q4pxsyg.js +2 -0
  3. package/dist/chunk-bmj5dnhd.js +1 -0
  4. package/dist/{chunk-exyqap7m.js → chunk-pz8xe0qj.js} +1 -1
  5. package/dist/{chunk-xdkdc1f0.js → chunk-qk8kg62t.js} +1 -1
  6. package/dist/src/aleo/index.js +1 -1
  7. package/dist/src/aptos/index.js +1 -1
  8. package/dist/src/cardano/index.js +1 -1
  9. package/dist/src/cosmos/index.js +1 -1
  10. package/dist/src/evm/index.js +1 -1
  11. package/dist/src/hypercore/index.js +1 -1
  12. package/dist/src/index.js +1 -1
  13. package/dist/src/lightspark/index.js +1 -1
  14. package/dist/src/near/index.js +1 -1
  15. package/dist/src/radix/index.js +1 -1
  16. package/dist/src/ripple/index.js +1 -1
  17. package/dist/src/solana/index.js +1 -1
  18. package/dist/src/starknet/index.js +1 -1
  19. package/dist/src/stellar/index.js +1 -1
  20. package/dist/src/substrate/index.js +1 -1
  21. package/dist/src/sui/index.js +1 -1
  22. package/dist/src/ton/index.js +1 -1
  23. package/dist/src/tron/index.js +1 -1
  24. package/dist/src/utxo/index.js +2 -1
  25. package/dist/types/evm/helpers.d.ts +4 -0
  26. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +1 -1
  27. package/dist/types/evm/toolbox/evm.d.ts +24 -24
  28. package/dist/types/evm/toolbox/op.d.ts +2 -2
  29. package/dist/types/evm/types.d.ts +2 -2
  30. package/dist/types/hypercore/payin.d.ts +0 -1
  31. package/dist/types/sui/__tests__/grpcClientMock.d.ts +37 -0
  32. package/dist/types/utxo/__tests__/fixtures/utxo.d.ts +1 -0
  33. package/dist/types/utxo/helpers/index.d.ts +1 -0
  34. package/dist/types/utxo/helpers/messageSigning.d.ts +7 -0
  35. package/dist/types/utxo/toolbox/bitcoinCash.d.ts +1 -0
  36. package/dist/types/utxo/toolbox/utxo.d.ts +1 -0
  37. package/dist/types/utxo/toolbox/zcash.d.ts +1 -0
  38. package/package.json +2 -4
  39. package/dist/chunk-ncc6qmj6.js +0 -1
  40. package/dist/chunk-ygq25ce3.js +0 -2
@@ -1 +1,2 @@
1
- import{ha as St,ia as jt}from"../../chunk-xdkdc1f0.js";import"../../chunk-exyqap7m.js";import{NetworkDerivationPath as Cn}from"@swapkit/helpers";function z(e,t){if(!Number.isInteger(t)||t<0)throw RangeError(`${e} must be a non-negative integer, got: ${t}`)}function te({accountIndex:e,chain:t,derivationPath:n}){if(e!==void 0)z("accountIndex",e);let[r,s,a]=n??Cn[t];return[r,s,e??a]}function Ae({accountIndex:e,change:t=!1,chain:n,derivationPath:r,index:s}){return z("index",s),[...te({accountIndex:e,chain:n,derivationPath:r}),Number(t),s]}function pe(e){return e[2]??0}function Xn({deriveAddress:e,getBalance:t,getUtxos:n}){async function r(o){let{accountIndex:p,count:c,startIndex:u=0,change:i=!1}=o;if(z("count",c),c<1)throw RangeError("count must be at least 1");z("startIndex",u);let l=[];for(let h=0;h<c;h++){let m=await e({accountIndex:p,change:i,index:u+h});if(m)l.push(m)}return l}async function s(o){let{gapLimit:p=20,change:c=!1}=o??{},u=[],i=0,l=0;while(i<p){let h=await e({change:c,index:l});if(!h)break;if((await t(h.address)).some((y)=>y.getValue("number")>0))u.push(h),i=0;else i++;l++}return u}async function a(o=20){let[p,c]=await Promise.all([s({change:!1,gapLimit:o}),s({change:!0,gapLimit:o})]),u=[...p,...c],i=await Promise.all(u.map(async(h)=>{let f=(await t(h.address)).reduce((y,b)=>y+b.getValue("number"),0);return{...h,balance:f}})),l=i.reduce((h,m)=>h+m.balance,0);return{addresses:i,total:l}}async function d(o=20){let[p,c]=await Promise.all([s({change:!1,gapLimit:o}),s({change:!0,gapLimit:o})]),u=[...p,...c];return(await Promise.all(u.map(async(l)=>(await n(l.address)).map((m)=>({...m,address:l.address,derivationIndex:l.index,isChange:l.change}))))).flat()}return{deriveAddresses:r,getAggregatedBalance:a,getAggregatedUtxos:d,scanForAddresses:s}}import{Chain as C,getRPCUrl as Bn,RequestClient as Re,SKConfig as kn,SwapKitError as R,warnOnce as Kn}from"@swapkit/helpers";import{NETWORKS as le}from"@swapkit/utxo-signer";async function Fn({chain:e,txHash:t}){let n=`${he(e)}/push/transaction`,r=JSON.stringify({data:t});try{let s=await Re.post(n,{body:r,headers:{"Content-Type":"application/json"}});if(s.context.code!==200)throw new R("toolbox_utxo_broadcast_failed",{error:s.context.error||"Transaction broadcast failed"});return s.data?.transaction_hash||t}catch(s){let a=await Bn(e);if(a){let d=JSON.stringify({id:St(),jsonrpc:"2.0",method:"sendrawtransaction",params:[t]}),o=await Re.post(a,{body:d,headers:{"Content-Type":"application/json"}});if(o.error)throw new R("toolbox_utxo_broadcast_failed",{error:o.error?.message});if(o.result.includes('"code":-26'))throw new R("toolbox_utxo_invalid_transaction",{error:"Transaction amount was too low"});return o.result}throw s}}function he(e){return`https://api.blockchair.com/${Dn(e)}`}function At(e){switch(e){case C.Bitcoin:return 5;case C.Dogecoin:return 1e4;case C.Litecoin:return 1;case C.Zcash:return 1;default:return 2}}function Dn(e){switch(e){case C.BitcoinCash:return"bitcoin-cash";case C.Litecoin:return"litecoin";case C.Dash:return"dash";case C.Dogecoin:return"dogecoin";case C.Zcash:return"zcash";case C.Polkadot:return"polkadot";default:return"bitcoin"}}async function In(e){try{let{feePerKb:t}=await Re.get(`https://app.bitgo.com/api/v2/${e.toLowerCase()}/tx/fee`),n=t/1000;return Math.max(n,At(e))}catch{return At(e)}}async function Oe(e,t){let n=await Re.get(`${e}${t?`${e.includes("?")?"&":"?"}key=${t}`:""}`);if(!n||n.context.code!==200)throw new R("toolbox_utxo_api_error",{error:`Failed to query ${e}`});return n.data}async function Hn({chain:e,apiKey:t}){let n=await Oe(`${he(e)}/stats`,t);if(typeof n.best_block_height!=="number")throw new R("toolbox_utxo_api_error",{error:"Missing best_block_height in stats response"});return n.best_block_height}async function Ct({address:e,chain:t,apiKey:n}){if(!e)throw new R("toolbox_utxo_invalid_params",{error:"Address is required"});try{return(await Oe(`${he(t)}/dashboards/address/${e}?transaction_details=true`,n))[e]}catch{return{address:{balance:0,transaction_count:0},utxo:[]}}}async function Rn({address:e,chain:t,apiKey:n}){return(await Ct({address:e,apiKey:n,chain:t}))?.address.balance||0}async function Xt({chain:e,apiKey:t,txHash:n}){if(!n)throw new R("toolbox_utxo_invalid_params",{error:"TxHash is required"});try{return(await Oe(`${he(e)}/raw/transaction/${n}`,t))?.[n]?.raw_transaction||""}catch(r){let s=r instanceof Error?r.message:String(r);return console.error(`Failed to fetch raw transaction: ${s}`),""}}var En=4294967294;async function Mn({chain:e,apiKey:t,txHash:n}){if(!n)throw new R("toolbox_utxo_invalid_params",{error:"TxHash is required"});let s=(await Oe(`${he(e)}/dashboards/transaction/${n}`,t))?.[n];if(!s)throw new R("toolbox_utxo_tx_not_found",{txHash:n});let{transaction:a,inputs:d,outputs:o}=s,p=d.map((u)=>u.spending_sequence),c=a.is_rbf===!0||p.some((u)=>u<En);return{blockId:a.block_id,confirmed:a.block_id!==-1,fee:a.fee,inputs:d,isRBF:c,outputs:o,sequences:p,size:a.size,txid:a.hash,weight:a.weight}}async function Nn({chain:e,address:t,apiKey:n,offset:r=0,limit:s=30}){return(await Oe(`${he(e)}/outputs?q=recipient(${t}),is_spent(false)&s=value(desc)&fields=is_spent,transaction_hash,index,value,script_hex,block_id,spending_signature_hex&limit=${s}&offset=${r}`,n)).map(({is_spent:p,script_hex:c,block_id:u,transaction_hash:i,index:l,value:h,spending_signature_hex:m})=>({hash:i,index:l,is_confirmed:u!==-1,is_spent:p,script_hex:c,txHex:m,value:h}))}function Zn(e){return e.reduce((t,n)=>t+n.value,0)}function Ot(e,t){let n=[...e].sort((r,s)=>s.value-r.value);if(t){let r=[],s=0;for(let a of n)if(r.push(a),s+=a.value,s>=t)break;return r}return n}async function Bt({chain:e,address:t,apiKey:n,targetValue:r,accumulativeValue:s=0,offset:a=0,limit:d=30}){if(!t)throw new R("toolbox_utxo_invalid_params",{error:"Address is required"});try{let o=await Nn({address:t,apiKey:n,chain:e,limit:d,offset:a,targetValue:r}),c=o.length<d,u=o.filter(({is_spent:y})=>!y),i=Zn(u),l=s+i,h=r&&l>=r;if(c||h)return Ot(u,r);let m=await Bt({accumulativeValue:l,address:t,apiKey:n,chain:e,limit:d,offset:a+d,targetValue:r}),f=[...u,...m];return Ot(f,r)}catch(o){let p=o instanceof Error?o.message:String(o);return console.error(`Failed to fetch unspent UTXOs: ${p}`),[]}}async function zn({address:e,chain:t,apiKey:n,fetchTxHex:r=!0,targetValue:s}){let a=await Bt({address:e,apiKey:n,chain:t,targetValue:s}),d=r?await Promise.all(a.map(({hash:o})=>Xt({apiKey:n,chain:t,txHash:o}))):[];return a.map(({hash:o,index:p,script_hex:c,value:u},i)=>({address:e,hash:o,index:p,txHex:r?d[i]:void 0,value:u,witnessUtxo:{script:Buffer.from(c,"hex"),value:u}}))}function A(e){let t=kn.get("apiKeys").blockchair||"";return Kn({condition:!t,id:"no_blockchair_api_key_warning",warning:"No Blockchair API key found. Functionality will be limited."}),{broadcastTx:(n)=>Fn({chain:e,txHash:n}),getAddressData:(n)=>Ct({address:n,apiKey:t,chain:e}),getBalance:(n)=>Rn({address:n,apiKey:t,chain:e}),getBlockHeight:()=>Hn({apiKey:t,chain:e}),getRawTx:(n)=>Xt({apiKey:t,chain:e,txHash:n}),getSuggestedTxFee:()=>In(e),getTransactionDetails:(n)=>Mn({apiKey:t,chain:e,txHash:n}),getUtxos:(n)=>zn({...n,apiKey:t,chain:e})}}function Hs(e){return e}function Rs(){return function(t){switch(t){case C.Bitcoin:return le.bitcoin;case C.BitcoinCash:return le.bitcoinCash;case C.Dash:return le.dash;case C.Litecoin:return le.litecoin;case C.Dogecoin:return le.dogecoin;case C.Zcash:return le.zcash;default:throw new R("toolbox_utxo_not_supported",{chain:t})}}}import{sha256 as Yn}from"@noble/hashes/sha2.js";import{createBase58check as jn}from"@scure/base";import{SwapKitError as Kt}from"@swapkit/helpers";import{CashAddrType as Ee,decodeCashAddr as Wn,encodeCashAddr as Ln}from"@swapkit/utxo-signer";var $n={P2PKH:Ee.P2PKH,P2SH:Ee.P2SH},Vn={[Ee.P2PKH]:"P2PKH",[Ee.P2SH]:"P2SH"};function qn(e,t,n){return Ln({hash:n,prefix:e,type:$n[t]})}function Gn(e){let t=Wn(e),n=Vn[t.type];if(!n)throw Error(`Unknown CashAddr type: ${t.type}`);return{hash:t.hash,prefix:t.prefix,type:n}}var ot={decode:Gn,encode:qn};var Ft=jn(Yn);var Dt;((n)=>{n.Mainnet="mainnet";n.Testnet="testnet"})(Dt||={});var ne={["legacy"]:{["mainnet"]:{["p2pkh"]:0,["p2sh"]:5},["testnet"]:{["p2pkh"]:111,["p2sh"]:196}},["bitpay"]:{["mainnet"]:{["p2pkh"]:28,["p2sh"]:40},["testnet"]:{["p2pkh"]:111,["p2sh"]:196}}},Jn={["p2pkh"]:"pkh",["p2sh"]:"sh"};function $s(e){return Ne(e)!==void 0}function Vs(e){return at(e).network}function G(e){let t=at(e);if(t.format==="legacy")return e;return tr(t)}function Me(e){let t=at(e);return nr(t)}function Ne(e){if(typeof e!=="string")return;let t=Qn(e)??er(e);return t&&{...t,scriptType:Jn[t.type]}}function at(e){let t=Ne(e);if(!t)throw new Kt("toolbox_utxo_invalid_address",{address:e});return t}function Qn(e){try{let t=Ft.decode(e);if(t.length!==21)throw new Kt("toolbox_utxo_invalid_address",{address:e});let n=t[0],r=Array.prototype.slice.call(t,1);switch(n){case ne.legacy.mainnet.p2pkh:return{format:"legacy",hash:r,network:"mainnet",type:"p2pkh"};case ne.legacy.mainnet.p2sh:return{format:"legacy",hash:r,network:"mainnet",type:"p2sh"};case ne.legacy.testnet.p2pkh:return{format:"legacy",hash:r,network:"testnet",type:"p2pkh"};case ne.legacy.testnet.p2sh:return{format:"legacy",hash:r,network:"testnet",type:"p2sh"};case ne.bitpay.mainnet.p2pkh:return{format:"bitpay",hash:r,network:"mainnet",type:"p2pkh"};case ne.bitpay.mainnet.p2sh:return{format:"bitpay",hash:r,network:"mainnet",type:"p2sh"};default:return}}catch{return}}function er(e){if(e.indexOf(":")!==-1)try{return kt(e)}catch{}else{let t=["bitcoincash","bchtest","bchreg"];for(let n of t)try{return kt(`${n}:${e}`)}catch{}}return}function kt(e){try{let{hash:t,prefix:n,type:r}=ot.decode(e);return{format:"cashaddr",hash:Array.prototype.slice.call(t,0),network:n==="bitcoincash"?"mainnet":"testnet",type:r==="P2PKH"?"p2pkh":"p2sh"}}catch{return}}function tr(e){let t=ne.legacy[e.network][e.type],n=Buffer.alloc(1+e.hash.length);return n[0]=t,n.set(e.hash,1),Ft.encode(n)}function nr(e){let t=e.network==="mainnet"?"bitcoincash":"bchtest",n=e.type==="p2pkh"?"P2PKH":"P2SH",r=new Uint8Array(e.hash);return ot.encode(t,n,r)}import{Chain as ae,SwapKitError as mt}from"@swapkit/helpers";import{SwapKitError as qe,UTXO_SCRIPT_TYPE_LIST as Ar,UTXO_SCRIPT_TYPES as $t,UTXOScriptType as Ge}from"@swapkit/helpers";import{Script as Or}from"@swapkit/utxo-signer";import{Chain as it}from"@swapkit/helpers";import{getAddressScriptType as sr,getTransparentZcashAddressType as or,getZcashAddressType as ar}from"@swapkit/utxo-signer";import{match as ir}from"ts-pattern";import{Chain as fe}from"@swapkit/helpers";import{NETWORKS as Te}from"@swapkit/utxo-signer";import{match as rr}from"ts-pattern";function U(e){return rr(e).with(fe.Bitcoin,()=>Te.bitcoin).with(fe.BitcoinCash,()=>Te.bitcoinCash).with(fe.Dash,()=>Te.dash).with(fe.Dogecoin,()=>Te.dogecoin).with(fe.Litecoin,()=>Te.litecoin).with(fe.Zcash,()=>Te.zcash).exhaustive()}function W(e){return e.replace(/(bchtest:|bitcoincash:)/,"")}function Se(e){if(typeof e!=="string")return null;let t=Ne(W(e));if(!t||t.network!=="mainnet")return null;return t.scriptType}var cr=["sprout","sapling","unified"];function dr(e){let t=or(e,U(it.Zcash));if(t)return t;let n=ar(e);return n&&cr.includes(n)?n:null}function Y({address:e,chain:t}){return ir(t).with(it.BitcoinCash,()=>Se(e)).with(it.Zcash,()=>dr(e)).otherwise(()=>sr(e,U(t)))}import{Chain as re,derivationPathToString as It,getPurposeFromPath as ur,getUTXOScriptTypeForPath as Ht,getUTXOScriptTypeForPurpose as Mt,resolveDerivationPath as pr,SwapKitError as Ce,UTXO_SCRIPT_TYPE_LIST as Rt,UTXO_SCRIPT_TYPES as me,UTXOChains as lr,UTXOScriptType as O,updateDerivationPath as hr,warnOnce as fr}from"@swapkit/helpers";import{CashAddrPrefix as Tr,CashAddrType as mr,encodeCashAddr as yr,OutScript as Nt,p2pkh as gr,p2sh as xr,p2tr as br,p2wpkh as Et}from"@swapkit/utxo-signer";var Ze=Object.freeze([O.P2PKH]),wr=Object.freeze({[re.Bitcoin]:Rt,[re.BitcoinCash]:Ze,[re.Dash]:Ze,[re.Dogecoin]:Ze,[re.Litecoin]:Rt,[re.Zcash]:Ze});function We(e){return wr[e]}function ct(e){return We(e).some((t)=>me[t].witness)}function ye(e,t){return We(e).includes(t)}function Le(e,t){if(ye(e,t))return t;throw new Ce("toolbox_utxo_unsupported_script_type",{chain:e,error:`${e} cannot encode ${t}; supported: ${We(e).join(", ")}`,scriptType:t,supported:We(e)})}var Zt=lr.filter((e)=>!ct(e));function Pr({purpose:e,scriptType:t}){let n=Mt(e);return n===void 0||n===t}function dt({chain:e,purpose:t,scriptType:n}){fr({condition:!Pr({purpose:t,scriptType:n}),id:`utxo_off_standard_encoding_${e}_${t}_${n}`,warning:`${e}: encoding m/${t}' keys as ${n}, not the ${Mt(t)} the path implies. No other wallet derives these addresses: move funds out of them, never receive into them.`})}function $e({chain:e,derivationPath:t,index:n=0,scriptType:r}){if(t){if(!r){let o=Ht(t);throw new Ce("toolbox_utxo_invalid_params",{chain:e,derivationPath:It(t),error:`scriptType is required alongside derivationPath: getUTXOScriptTypeForPath gives the standard one${o?` (${o})`:""}, or state another deliberately.`})}return Le(e,r),dt({chain:e,purpose:ur(t),scriptType:r}),{derivationPath:t,scriptType:r}}let s=pr({chain:e,index:n}),a=r?hr(s,{purpose:me[r].purpose}):s,d=r??Ht(a);if(!d)throw new Ce("toolbox_utxo_invalid_params",{chain:e,derivationPath:It(a),error:`${e}: the default derivation path has no standard script type`});return Le(e,d),{derivationPath:a,scriptType:d}}function Ur(e){return e.length===32?e:e.slice(1)}function ze(e,t){if(!e.address)throw new Ce("toolbox_utxo_invalid_address",{error:`Could not derive a ${t} address`});return e}var vr={[O.P2PKH]:(e,t)=>{let{address:n,script:r}=ze(gr(e,t),O.P2PKH);return{address:n,script:r}},[O.P2SH_P2WPKH]:(e,t)=>{let n=Et(e,t),{address:r,script:s}=ze(xr(n,t),O.P2SH_P2WPKH);return{address:r,redeemScript:n.script,script:s}},[O.P2WPKH]:(e,t)=>{let{address:n,script:r}=ze(Et(e,t),O.P2WPKH);return{address:n,script:r}},[O.P2TR]:(e,t)=>{let n=Ur(e),{address:r,script:s}=ze(br(n,void 0,t),O.P2TR);return{address:r,script:s,tapInternalKey:n}}};function Ve(e,t,n){return vr[e](t,n)}function ut(e,t){if(e!==re.BitcoinCash)return t.address;let n=Nt.decode(t.script);if(n.type!=="pkh")throw new Ce("toolbox_utxo_invalid_address",{chain:e,error:`Cannot encode ${n.type} as CashAddr`});return yr({hash:n.hash,prefix:Tr.MAINNET,type:mr.P2PKH}).replace(/^bitcoincash:/,"")}var _r=Object.freeze({pkh:O.P2PKH,sh:O.P2SH_P2WPKH,tr:O.P2TR,wpkh:O.P2WPKH}),zt=Object.freeze({pkh:me[O.P2PKH].outputSize,sh:me[O.P2SH_P2WPKH].outputSize,tr:me[O.P2TR].outputSize,wpkh:me[O.P2WPKH].outputSize,wsh:43});function Wt(e){return e in zt}function Lt(e){return Wt(e)?zt[e]:void 0}function Xe(e){return _r[e]}function pt(e){try{let{type:t}=Nt.decode(e);return Wt(t)?Xe(t):void 0}catch{return}}import{UTXOScriptType as oe}from"@swapkit/helpers";var ho=1000,ht=10,Sr=2,Cr=10;function E(e){let t=new Uint8Array(Buffer.from(e,"utf8"));return Or.encode(["RETURN",t])}function Vt(e){return Object.fromEntries(Ar.map((t)=>[t,$t[t][e]]))}var qt=Vt("inputSize"),lt=Vt("outputSize"),ft=(e)=>$t[e].witness,Ye=(e,t)=>{let n=Y({address:e,chain:t});if(!n)throw new qe("toolbox_utxo_invalid_address",{address:e,chain:t});let r=Xe(n);if(!r||!ye(t,r))throw new qe("toolbox_utxo_unsupported_script_type",{address:e,addressType:n,chain:t,error:"Address is valid but its script type is not one the SDK spends from"});return r},Xr=(e,t)=>{let n=Y({address:e,chain:t});if(!n)throw new qe("toolbox_utxo_invalid_address",{address:e,chain:t});let r=Lt(n);if(!r)throw new qe("toolbox_utxo_unsupported_script_type",{address:e,addressType:n,chain:t,error:"Address is valid but a transparent transaction cannot pay to it"});return r},ge=({chain:e,inputs:t,outputs:n,feeRate:r})=>{let s=t[0]?Be(t[0],e):Ge.P2PKH,a=r?t.filter((u)=>u.value>=qt["type"in u&&u.type?u.type:Ge.P2PKH]*Math.ceil(r)):t,d=0,o=0;for(let u of a)if(d+=se(u,e),!ft(Be(u,e)))o++;let p=n?.reduce((u,i)=>u+je(i,e),0)||lt[s],c=o<a.length;return ht+d+p+Tt(c,o)},Be=(e,t)=>{if("type"in e&&e.type)return e.type;if("address"in e&&e.address)return Ye(e.address,t);return Ge.P2PKH},se=(e,t)=>qt[Be(e,t)],Tt=(e,t)=>e?Math.ceil((Sr+t)/4):0,je=(e,t,n)=>{if(e?.script)return Cr+e.script.length+(e.script.length>=74?2:1);if(n)return lt[n];if("address"in e&&e.address)return Xr(e.address,t);return lt[Ge.P2PKH]};function ke(e){switch(e){case ae.Bitcoin:case ae.BitcoinCash:return 550;case ae.Dash:case ae.Litecoin:return 5500;case ae.Dogecoin:return 1e5;case ae.Zcash:return 546;default:throw new mt("toolbox_utxo_not_supported",{chain:e})}}function M({inputs:e,outputs:t,feeRate:n=1,chain:r=ae.Bitcoin,changeAddress:s="",sweep:a=!1}){let d=ke(r),o=e.filter((f)=>{let y=se(f,r)*n;return a?f.value>Math.max(y,d):y<=f.value});if(a){let f=Math.ceil(n*ge({chain:r,inputs:o,outputs:t})),y=o.reduce((X,V)=>X+V.value,0),b=y-f;if(b<=d)throw new mt("toolbox_sweep_amount_too_low",{available:y,dustThreshold:d,fee:f});let S=t.findIndex((X)=>("address"in X)&&X.address);if(S===-1)throw new mt("toolbox_utxo_invalid_params",{error:"Sweep requires a recipient output"});return{fee:f,inputs:o,outputs:t.map((X,V)=>V===S?{...X,value:b}:X)}}let p=ht+t.reduce((f,y)=>f+je(y,r),0),c=t.reduce((f,y)=>f+y.value,0),u=0,i=0,l=!1,h=0,m=[];for(let f of o){if(u+=se(f,r),ft(Be(f,r)))l=!0;else i++;h+=f.value,m.push(f);let y=(p+u+Tt(l,i))*n,b=y+c;if(h<b)continue;let S=h-b,X=n*je({address:s,value:0},r);if(S>X){let V=X+y,Pe=h-(c+Math.ceil(V));if(Pe>Math.max(se({value:0},r)*n,ke(r)))return{fee:Math.ceil(V),inputs:m,outputs:t.concat({address:s,value:Pe})}}return{fee:Math.ceil(y),inputs:m,outputs:t}}return{fee:Math.ceil(n*ge({chain:r,inputs:e,outputs:t}))}}import{Chain as we,SwapKitError as Bs}from"@swapkit/helpers";import{hex as un}from"@scure/base";import{Chain as Yr,derivationPathToString as jr,FeeOption as Jr,resolveDerivationPath as Qr,SwapKitError as L}from"@swapkit/helpers";import{BCHSigHash as es,CashAddrPrefix as pn,CashAddrType as ln,encodeCashAddr as hn,NETWORKS as ts,p2pkh as fn,Transaction as Tn}from"@swapkit/utxo-signer";import{secp256k1 as Br}from"@noble/curves/secp256k1.js";import{hex as j}from"@scure/base";import{HDKey as Jt}from"@scure/bip32";import{mnemonicToSeedSync as xt}from"@scure/bip39";import{AssetValue as yt,applyFeeMultiplier as Gt,Chain as Fe,derivationPathToString as Ke,FeeOption as N,NetworkDerivationPath as kr,SwapKitError as P,SwapKitNumber as Kr,UTXO_SCRIPT_TYPES as Fr,warnOnce as Dr}from"@swapkit/helpers";import{BCHSigHash as Qt,RBF_SEQUENCE as Ir,SigHash as Yt,Transaction as Je,utils as Hr,WIF as en}from"@swapkit/utxo-signer";var Qe=[Fe.Bitcoin];function tn({address:e,chain:t}){return Y({address:e,chain:t})!==null}function Rr({phrase:e,derivationPath:t,network:n,seed:r}){let s=r??xt(e),d=Jt.fromMasterSeed(s,n.bip32).derive(t);if(!d.privateKey)throw new P("toolbox_utxo_invalid_params",{error:"Could not derive private key from phrase"});return d.privateKey}function gt(e){return Br.getPublicKey(e,!0)}function De({publicKey:e,chain:t,network:n,scriptType:r}){return ut(t,Ve(r,e,n))}function xe({phrase:e,derivationPath:t,chain:n,wif:r,seed:s}){let a=U(n);if(r){let c=en(a).decode(r),u=gt(c);return{privateKey:c,publicKey:u}}if(!e)throw new P("toolbox_utxo_invalid_params",{error:"Either phrase or wif must be provided"});let d=t||Ke(kr[n]),o=Rr({derivationPath:d,network:a,phrase:e,seed:s}),p=gt(o);return{privateKey:o,publicKey:p}}function Er(e,t){return en(U(t)).encode(e)}function Mr({phrase:e,derivationPath:t,chain:n,seed:r}){let s=t.split("/");if(s.length<4)throw new P("toolbox_utxo_invalid_params",{error:`Derivation path must have at least 4 levels (got ${s.length}): ${t}`});let a=U(n),d=r??xt(e),o=Jt.fromMasterSeed(d,a.bip32),p=s.slice(0,4).join("/");return o.derive(p)}function Nr(e,t){if(!e||!Fr[e].witness)return!1;return e!==oe.P2SH_P2WPKH||!!t}function nn({chain:e,script:t,publicKey:n,network:r}){let s=pt(t);if(s!==oe.P2SH_P2WPKH&&s!==oe.P2TR)return{};if(!ye(e,s))return{};let a=Ve(s,n,r);if(Hr.compareBytes(a.script,t)!==0)return{};return s===oe.P2TR?{tapInternalKey:a.tapInternalKey}:{redeemScript:a.redeemScript}}function Zr(e,t,n){if(!n)return!1;let r=Y({address:e,chain:t}),s=r?Xe(r):void 0;if(!s||!ye(t,s))return!1;let a=ut(t,Ve(s,n,U(t)));return t===Fe.BitcoinCash?W(a)===W(e):a===e}function zr(e){return e.witnessUtxo?.script??e.nonWitnessUtxo?.outputs[e.index??0]?.script}function bt({chain:e,tx:t,publicKey:n,network:r,indexes:s}){let a=s??Array.from({length:t.inputsLength},(o,p)=>p),d=[];for(let o of a){let p=t.getInput(o),c=zr(p);if(!c)continue;let{redeemScript:u,tapInternalKey:i}=nn({chain:e,network:r,publicKey:n,script:c}),l={index:o};if(u&&!p.redeemScript)l.redeemScript=u;if(i&&!p.tapInternalKey)l.tapInternalKey=i;if(l.redeemScript||l.tapInternalKey)d.push(l)}return d}function ie({inputs:e,outputs:t,chain:n,tx:r,sender:s,compiledMemo:a,enableRBF:d=!1}){let o=U(n),p=ct(n),c=d?Ir:void 0,u=new Set;for(let i of e){let l=`${i.hash}:${i.index}`;if(u.has(l))throw new P("toolbox_utxo_invalid_params",{error:"Duplicate input detected"});u.add(l);let h=typeof i.hash==="string"?j.decode(i.hash):i.hash,m=i.witnessUtxo?pt(i.witnessUtxo.script):void 0,f=i.publicKey&&i.witnessUtxo?nn({chain:n,network:o,publicKey:i.publicKey,script:i.witnessUtxo.script}):{};if(p&&i.witnessUtxo&&Nr(m,f.redeemScript))r.addInput({...f,index:i.index,sequence:c,txid:h,witnessUtxo:{amount:BigInt(i.witnessUtxo.value),script:i.witnessUtxo.script}});else if(i.txHex)r.addInput({...f,index:i.index,nonWitnessUtxo:j.decode(i.txHex),sequence:c,txid:h,...n===Fe.BitcoinCash?{sighashType:Qt.ALL}:{}});else throw new P("toolbox_utxo_invalid_params",{error:`Input ${l} cannot be signed from its witnessUtxo alone: it needs its previous transaction (txHex), or — if it is a nested-segwit output — the public key that controls it, which its redeemScript derives from`})}for(let i of t){let l="address"in i&&i.address?i.address:s;if(n===Fe.BitcoinCash)l=G(l);if(i.script)if(a)r.addOutput({amount:0n,script:a});else throw new P("toolbox_utxo_invalid_params",{error:"An output carrying a script needs the compiled memo it carries"});else r.addOutputAddress(l,BigInt(i.value),o)}return{inputs:e,tx:r}}async function be(e){let t=await A(e).getSuggestedTxFee();return{[N.Average]:t,[N.Fast]:Gt(t,N.Fast),[N.Fastest]:Gt(t,N.Fastest)}}async function rn({assetValue:e,recipient:t,memo:n,sender:r,sweep:s,fetchTxHex:a=!1,publicKey:d},o,{forEstimateOnly:p=!1}={}){let c=e.chain,u=Ye(r,c),i=u===oe.P2PKH||u===oe.P2SH_P2WPKH&&!Zr(r,c,d),l=a||!p&&i,h=e.getBaseValue("number"),m=s?void 0:o??(await be(c))[N.Fastest],f=s||m===void 0?void 0:Math.ceil(h+m*5000);return{inputs:await A(c).getUtxos({address:r,fetchTxHex:l,targetValue:f}),outputs:[{address:t,value:s?0:h},...n?[{address:"",script:E(n),value:0}]:[]]}}async function sn({assetValue:e,recipient:t,memo:n,feeRate:r,sender:s,fetchTxHex:a=!1,enableRBF:d=!1,sweep:o,publicKey:p}){let c=e.chain,u=n?E(n):null,i=await rn({assetValue:e,fetchTxHex:a,memo:n,publicKey:p,recipient:t,sender:s,sweep:o},r),{inputs:l,outputs:h}=M({...i,chain:c,changeAddress:s,feeRate:r,sweep:o});if(!(l&&h))throw new P("toolbox_utxo_insufficient_balance",{assetValue:e,sender:s});let m=p?l.map((S)=>({...S,publicKey:p})):l,f=new Je({allowUnknownOutputs:!!u,version:1}),{inputs:y,tx:b}=ie({chain:c,compiledMemo:u,enableRBF:d,inputs:m,outputs:h,sender:s,tx:f});return{inputs:y,tx:b,utxos:i.inputs}}async function on({assetValue:e,feeOptionKey:t=N.Fast,feeRate:n,memo:r,sender:s,recipient:a,sweep:d}){let o=e.chain,p,c;if(n!==void 0)p=n,c=Math.floor(n);else{let i=await be(o);p=i[N.Fastest],c=i[t]}let u=await rn({assetValue:e,memo:r,recipient:a,sender:s,sweep:d},p,{forEstimateOnly:!0});return M({...u,chain:o,changeAddress:s,feeRate:c,sweep:d})}function Wr(e){return async function({from:n,memo:r,feeRate:s,feeOptionKey:a=N.Fast,recipient:d=n,recipients:o=1}){let p=s??(await be(e))[a],u=(await A(e).getUtxos({address:n,fetchTxHex:!1})).filter((f)=>f.value>Math.max(ke(e),se(f,e)*p));if(!u.length)return yt.from({chain:e});let i=typeof o==="number"?Math.max(o,1):o.length,l=typeof o==="number"||i===0?Array.from({length:i||1},()=>({address:d,value:0})):[...o];if(r)l.push({address:n,script:E(r),value:0});let{outputs:h}=M({chain:e,feeRate:p,inputs:u,outputs:l,sweep:!0}),m=h?.[0]?.value??0;return yt.from({chain:e,value:BigInt(m)})}}function Lr(e){return async function(n){let{fee:r}=await on(n);return yt.from({chain:e,value:Kr.fromBigInt(BigInt(r),8).getValue("string")})}}function $r({chain:e,phrase:t,derivationPath:n,scriptType:r,seed:s}){let a=U(e),{privateKey:d,publicKey:o}=xe({chain:e,derivationPath:n,phrase:t,seed:s}),p=an(e);return{getAddress:()=>De({chain:e,network:a,publicKey:o,scriptType:r}),privateKey:d,publicKey:o,signTransaction:(c)=>{for(let{index:u,...i}of bt({chain:e,network:a,publicKey:o,tx:c}))c.updateInput(u,i);return c.sign(d,p),c}}}function an(e){return e===Fe.BitcoinCash?[Qt.ALL]:[Yt.ALL,Yt.DEFAULT]}function Vr(e,t,n){return async function({memo:s,recipient:a,feeOptionKey:d,feeRate:o,assetValue:p,enableRBF:c=!1,sweep:u}){let i=await t?.getAddress();if(!(t&&i))throw new P("toolbox_utxo_no_signer");if(!a)throw new P("toolbox_utxo_invalid_params",{error:"Recipient address must be provided"});Dr({condition:c&&!Qe.includes(e),id:`rbf_not_supported_${e}`,warning:`RBF (Replace-by-Fee) is not reliably supported on ${e}. Transaction will be created without RBF signaling.`});let l=c&&Qe.includes(e),h=o||(await be(e))[d||N.Fast],{tx:m}=await sn({assetValue:p,enableRBF:l,feeRate:h,memo:s,publicKey:n,recipient:a,sender:i,sweep:u}),f=await t.signTransaction(m);return f.finalize(),A(e).broadcastTx(j.encode(f.extract()))}}function cn(e){return(t)=>tn({address:t,chain:e})}function dn(e,{scriptType:t}){let n=U(e);return function(s){if(!s)throw new P("toolbox_utxo_invalid_params",{error:"Keys must be provided"});return De({chain:e,network:n,publicKey:s.publicKey,scriptType:t})}}function qr(e){let t=e?.publicKey;if(t===void 0)return;if(t instanceof Uint8Array&&t.length===33)return t;throw new P("toolbox_utxo_invalid_params",{error:"signer.publicKey must be a 33-byte compressed public key (Uint8Array)"})}function ce(e){let{chain:t}=e,n=e.phrase?e:void 0;if(!n&&"derivationPath"in e&&e.derivationPath!==void 0)throw new P("toolbox_utxo_invalid_params",{error:"derivationPath needs a phrase; a toolbox built around a signer uses the signer's addresses"});let r=n?.phrase,s=n?.index??0,a=r?xt(r):void 0,{derivationPath:d,scriptType:o}=$e({chain:t,derivationPath:n?.derivationPath,index:s,scriptType:e.scriptType}),p=Ke(d),c=r?$r({chain:t,derivationPath:p,phrase:r,scriptType:o,seed:a}):void 0,u=n?void 0:e.signer,i=c||u,l=r?xe({chain:t,derivationPath:p,phrase:r,seed:a}):void 0,h=l?.publicKey??qr(u);function m(){if(i)return i.getAddress();return Promise.resolve(void 0)}function f(T){if(!r)return;let g=te({accountIndex:T,chain:t,derivationPath:d});return Mr({chain:t,derivationPath:Ke(g),phrase:r,seed:a})}let y=f();function b(){if(!y)return;return y.publicExtendedKey}function S({accountIndex:T}={}){let g=T===void 0?y:f(T);if(!g)return;let w=te({accountIndex:T,chain:t,derivationPath:d});return{accountIndex:pe(w),path:Ke(w),xpub:g.publicExtendedKey}}function X({accountIndex:T,index:g,change:w=!1}){let _=T===void 0?y:f(T);if(!_)return;let x=Ae({accountIndex:T,chain:t,change:w,derivationPath:d,index:g}),K=U(t),I=_.deriveChild(Number(w)).deriveChild(g);if(!I.publicKey)throw new P("toolbox_utxo_invalid_params",{error:"Could not derive public key"});let B=De({chain:t,network:K,publicKey:I.publicKey,scriptType:o}),F=j.encode(I.publicKey);return{accountIndex:pe(x),address:B,change:w,index:g,path:Ke(x),pubkey:F}}async function V(T){if(!Qe.includes(t))return{reason:`RBF is not supported on ${t}`,supported:!1};let g=await A(t).getTransactionDetails(T);return{canReplace:g.isRBF&&!g.confirmed,confirmed:g.confirmed,enabled:g.isRBF,fee:g.fee,sequences:g.sequences,supported:!0}}async function Pe({txid:T,newFeeRate:g,recipient:w,memo:_}){if(!Qe.includes(t))throw new P("toolbox_utxo_rbf_not_supported",{chain:t});let x=await A(t).getTransactionDetails(T);if(!x.isRBF)throw new P("toolbox_utxo_tx_not_replaceable",{txid:T});if(x.confirmed)throw new P("toolbox_utxo_tx_already_confirmed",{blockId:x.blockId,txid:T});let K=x.inputs.reduce((v,D)=>v+D.value,0),B=x.outputs.find((v)=>v.recipient===w)?.value||0;if(B===0)throw new P("toolbox_utxo_invalid_params",{error:"Could not determine send amount from original transaction"});let F=await Promise.all(x.inputs.map(async(v)=>{let D=await A(t).getRawTx(v.transaction_hash),k=Je.fromRaw(j.decode(D),{allowUnknownOutputs:!0,disableScriptCheck:!0}).getOutput(v.index);return{address:v.recipient,hash:v.transaction_hash,index:v.index,publicKey:h,txHex:D,value:v.value,witnessUtxo:k.script&&k.amount!==void 0?{script:Buffer.from(k.script),value:Number(k.amount)}:void 0}})),H=_?E(_):null,Q=K-B-x.fee,Ue=await m(),ue=[];if(H)ue.push({address:"",script:H,value:0});if(Q>ke(t)&&Ue)ue.push({address:Ue,value:Q});let He=ge({chain:t,inputs:F.map((v)=>({...v,type:Ye(v.address,t)})),outputs:[{address:w,value:B},...ue]}),q=Math.ceil(He*g);if(q<=x.fee)throw new P("toolbox_utxo_rbf_fee_too_low",{newFee:q,originalFee:x.fee});let ve=q-x.fee,ee=B-ve;if(ee<=0)throw new P("toolbox_utxo_rbf_insufficient_change");let _e=new Je({allowUnknownOutputs:!!H,version:1}),nt=[{address:w,value:ee},...ue];return ie({chain:t,compiledMemo:H,inputs:F,outputs:nt,sender:Ue||w,tx:_e}),{feeDelta:ve,newFee:q,originalFee:x.fee,tx:_e}}async function vn({txid:T,newFeeRate:g,recipient:w,memo:_}){let{tx:x,originalFee:K,newFee:I}=await Pe({memo:_,newFeeRate:g,recipient:w,txid:T}),B=await tt(x);B.finalize();let F=await A(t).broadcastTx(j.encode(B.extract()));return{newFee:I,originalFee:K,txid:F}}function vt({accountIndex:T,index:g,change:w=!1}){z("index",g);let _=T===void 0?y:f(T);if(!_)return;return _.deriveChild(Number(w)).deriveChild(g).privateKey||void 0}function _t({tx:T,inputDerivations:g}){if(!y)throw new P("toolbox_utxo_no_signer");let w=an(t),_=U(t);for(let x=0;x<g.length;x++){let K=g[x];if(!K)continue;let{derivationIndex:I,isChange:B}=K,F=vt({change:B,index:I});if(!F)throw new P("toolbox_utxo_invalid_params",{error:`Could not derive private key for input ${x} at index ${I}`});for(let{index:H,...Q}of bt({chain:t,indexes:[x],network:_,publicKey:gt(F),tx:T}))T.updateInput(H,Q);T.signIdx(F,x,w)}return T}async function _n({utxos:T,recipient:g,assetValue:w,memo:_,feeRate:x,feeOptionKey:K,changeAddress:I,sweep:B}){if(B)throw new P("toolbox_utxo_invalid_params",{error:"Sweep is not supported for transfers from multiple addresses"});if(!y)throw new P("toolbox_utxo_no_signer");let F=x||(await be(t))[K||N.Fast],H=_?E(_):null,Q=[{address:g,value:w.getBaseValue("number")}];if(H)Q.push({address:"",script:H,value:0});let Ue=T.map(({address:v,hash:D,index:k,value:rt,txHex:Sn,witnessUtxo:st})=>({address:v,hash:D,index:k,txHex:Sn,value:rt,witnessUtxo:st?{script:st.script,value:st.value}:void 0})),ue=T[0]?.address,He=I||await m()||ue||g,{inputs:q,outputs:ve}=M({chain:t,changeAddress:He,feeRate:F,inputs:Ue,outputs:Q});if(!(q&&ve))throw new P("toolbox_utxo_insufficient_balance",{assetValue:w,sender:"multiple addresses"});let ee=new Je({allowUnknownOutputs:!!H,version:1}),_e=q.map((v)=>{let D=T.find((k)=>k.hash===v.hash&&k.index===v.index);return D?{derivationIndex:D.derivationIndex,isChange:D.isChange}:{derivationIndex:0,isChange:!1}}),nt=q.map((v,D)=>{let k=_e[D],rt=k?y.deriveChild(Number(k.isChange)).deriveChild(k.derivationIndex).publicKey:null;return{...v,publicKey:rt??void 0}});return ie({chain:t,compiledMemo:H,inputs:nt,outputs:ve,sender:He,tx:ee}),_t({inputDerivations:_e,tx:ee}),ee.finalize(),A(t).broadcastTx(j.encode(ee.extract()))}function An({address:T,gapLimit:g=20}){if(!y)return;for(let w=0;w<g;w++){let _=X({change:!1,index:w}),x=X({change:!0,index:w}),K=_?.address===T?!1:x?.address===T;if(_?.address===T||x?.address===T)return{change:K,index:w}}return}function tt(T){if(!i)throw new P("toolbox_utxo_no_signer");return i.signTransaction(T)}async function On(T){let g=await tt(T);return g.finalize(),await A(t).broadcastTx(j.encode(g.extract()))}return{accumulative:M,broadcastTx:(T)=>A(t).broadcastTx(T),bumpFee:vn,calculateTxSize:(T)=>ge({...T,chain:t}),createKeysForPath:(T)=>xe({...T,chain:t}),createReplacementTransaction:Pe,createTransaction:(T)=>sn({publicKey:h,...T}),deriveAddressAtIndex:X,derivePrivateKeyAtIndex:vt,estimateMaxSendableAmount:Wr(t),estimateTransactionFee:Lr(t),getAddress:m,getAddressFromKeys:dn(t,{scriptType:o}),getAddressType:(T)=>Y({address:T,chain:t}),getBalance:jt(t),getExtendedPublicKey:b,getExtendedPublicKeyInfo:S,getFeeRates:()=>be(t),getInputsOutputsFee:on,getNetworkForChain:()=>U(t),getPrivateKeyFromMnemonic:(T)=>Er(xe({...T,chain:t}).privateKey,t),isRBFEnabled:V,keys:l,resolveDerivationIndex:An,scriptType:o,signAndBroadcastTransaction:On,signTransaction:tt,signTransactionWithMultipleKeys:_t,transfer:Vr(t,i,h),transferFromMultipleAddresses:_n,validateAddress:cn(t)}}import{getZcashAddressType as Gr,validateZcashAddress as wt}from"@swapkit/utxo-signer";function Ie(e){return Se(e)!==null}var Z=Yr.BitcoinCash;function et(e){return W(Me(e))}function ns(e){let t=U(Z);function n(s){return s.sign(e.privateKey,[es.ALL]),s}function r(){let s=fn(e.publicKey,t);if(!s.hash)throw new L("toolbox_utxo_invalid_address",{error:"Could not derive BCH address hash"});let a=hn({hash:s.hash,prefix:pn.MAINNET,type:ln.P2PKH});return Promise.resolve(a.replace(/^bitcoincash:/,""))}return{getAddress:r,signTransaction:n}}function mn(e={}){let t="phrase"in e?e.phrase:void 0,n="index"in e?e.index||0:0,r="derivationPath"in e?e.derivationPath:void 0,s=Qr({chain:Z,derivationPath:r,index:n}),a=jr(s),d=t?xe({chain:Z,derivationPath:a,phrase:t}):void 0,o=d?ns(d):("signer"in e)?e.signer:void 0;function p(){return Promise.resolve(o?.getAddress())}let c="scriptType"in e?e.scriptType:void 0,{getBalance:u,getFeeRates:i,broadcastTx:l,...h}=ce(t?{chain:Z,index:n,phrase:t,...r?{derivationPath:r,scriptType:c}:{scriptType:c}}:{chain:Z,scriptType:c});function m(b,S=!0){return u(W(Me(b)))}function f(b){if(!o)throw new L("toolbox_utxo_no_signer");return o.signTransaction(b)}async function y(b){let S=await f(b);return S.finalize(),await l(un.encode(S.extract()))}return{...h,broadcastTx:l,buildTx:ss,createTransaction:yn,getAddress:p,getAddressFromKeys:os,getBalance:m,getFeeRates:i,signAndBroadcastTransaction:y,signTransaction:f,stripPrefix:W,stripToCashAddress:et,transfer:rs({broadcastTx:l,getFeeRates:i,signer:o}),validateAddress:Ie}}async function yn({assetValue:e,recipient:t,memo:n,feeRate:r,sender:s,sweep:a}){if(!Ie(t))throw new L("toolbox_utxo_invalid_address",{address:t});let d=Math.ceil(e.getBaseValue("number")+r*7500),o=await A(Z).getUtxos({address:et(s),fetchTxHex:!0,targetValue:a?void 0:d}),p=n?E(n):null,c=[],u=G(t);if(c.push({address:u,value:a?0:e.getBaseValue("number")}),p)c.push({script:p,value:0});let{inputs:i,outputs:l}=M({chain:Z,feeRate:r,inputs:o,outputs:c,sweep:a});if(!(i&&l))throw new L("toolbox_utxo_insufficient_balance",{assetValue:e,sender:s});let h=new Tn({allowUnknownOutputs:!!p,version:1}),m=G(s),{inputs:f,tx:y}=ie({chain:Z,compiledMemo:p,inputs:i,outputs:l.map((b)=>("address"in b)&&b.address?{...b,address:G(b.address)}:b),sender:m,tx:h});return{inputs:f,tx:y,utxos:i}}function rs({broadcastTx:e,getFeeRates:t,signer:n}){return async function({recipient:s,assetValue:a,feeOptionKey:d=Jr.Fast,sweep:o,...p}){let c=await n?.getAddress();if(!(n&&c))throw new L("toolbox_utxo_no_signer");if(!s)throw new L("toolbox_utxo_invalid_params",{error:"Recipient address must be provided"});let u=p.feeRate||(await t())[d],{tx:i}=await yn({...p,assetValue:a,feeRate:u,recipient:s,sender:c,sweep:o}),l=await n.signTransaction(i);return l.finalize(),e(un.encode(l.extract()))}}async function ss({assetValue:e,recipient:t,memo:n,feeRate:r,sender:s}){let a=Me(t);if(!Ie(a))throw new L("toolbox_utxo_invalid_address",{address:a});let d=Math.ceil(e.getBaseValue("number")+r*7500),o=await A(Z).getUtxos({address:et(s),fetchTxHex:!0,targetValue:d}),p=Number(r.toFixed(0)),c=n?E(n):null,u=[];if(u.push({address:G(t),value:e.getBaseValue("number")}),c)u.push({script:c,value:0});let{inputs:i,outputs:l}=M({chain:Z,feeRate:p,inputs:o,outputs:u});if(!(i&&l))throw new L("toolbox_utxo_insufficient_balance",{assetValue:e,sender:s});let h=new Tn({allowUnknownOutputs:!!c,version:1}),{inputs:m,tx:f}=ie({chain:Z,compiledMemo:c,inputs:i,outputs:l,sender:G(s),tx:h});return{inputs:m,tx:f,utxos:o}}function os(e){let t=ts.bitcoinCash,n=fn(e.publicKey,t);if(!n.hash)throw new L("toolbox_utxo_invalid_address",{error:"Could not derive BCH address hash"});return hn({hash:n.hash,prefix:pn.MAINNET,type:ln.P2PKH}).replace(/^bitcoincash:/,"")}import{createBase58check as as,hex as is}from"@scure/base";import{HDKey as bn}from"@scure/bip32";import{mnemonicToSeedSync as wn}from"@scure/bip39";import{Chain as J,derivationPathToString as cs,FeeOption as ds,SwapKitError as de}from"@swapkit/helpers";import{Address as us,createZcashTransaction as ps,getZcashConsensusBranchId as ls,isTransparentZcashAddress as gn,OutScript as hs,PCZT as fs,utils as Pn,WIF as Ts,ZcashConsensusBranchId as ms,ZcashPSBT as ys,ZcashSigHash as Pt,ZcashVersionGroupId as gs}from"@swapkit/utxo-signer";import{match as xs,P as Ut}from"ts-pattern";var bs=as(Pn.sha256);function ws(e){return bs.encode(e)}function Ps({phrase:e,derivationPath:t}){let n=wn(e),s=bn.fromMasterSeed(n).derive(t);if(!s.privateKey||!s.publicKey)throw new de("toolbox_utxo_invalid_params");let{privateKey:a,publicKey:d}=s,o=Pn.hash160(d),p=new Uint8Array([28,184]),c=new Uint8Array(p.length+o.length);c.set(p,0),c.set(o,p.length);let u=ws(c);return{getAddress:()=>Promise.resolve(u),signTransaction:(i)=>{if(i instanceof ys){let l=i.toPCZT();return l.signAllInputs(a,d,Pt.ALL),l.finalizeAllInputs(),Promise.resolve(l.extract())}if(i instanceof fs)return i.signAllInputs(a,d,Pt.ALL),i.finalizeAllInputs(),Promise.resolve(i.extract());return i.signAllInputs(a,d,Pt.ALL),Promise.resolve(i)}}}function Us({inputs:e,outputs:t,tx:n,sender:r,compiledMemo:s}){let a=U(J.Zcash);for(let d of e){let o=us(a).decode(r),p=hs.encode(o);n.addInput({index:d.index,script:p,sequence:4294967295,txid:is.decode(d.hash),value:BigInt(d.value)})}for(let d of t){let o="address"in d&&d.address?d.address:r,p=d.script;if(p&&!s)continue;if(p&&s)n.addOutput({amount:0n,script:s});else n.addOutputAddress(o,BigInt(d.value),a)}return{inputs:e,tx:n}}async function vs(){try{let e=await A(J.Zcash).getBlockHeight();return ls(e+1)}catch{return ms.IRONWOOD}}async function xn(e){let{assetValue:t,recipient:n,memo:r,feeRate:s,sender:a,fetchTxHex:d,sweep:o}=e,p=U(J.Zcash);if(!gn(a,p))throw new de("toolbox_utxo_invalid_address",{address:a});if(!gn(n,p))throw new de("toolbox_utxo_invalid_address",{address:n,error:"Zcash transaction creation currently supports transparent addresses only"});let c=r?E(r):null,u=await A(J.Zcash).getUtxos({address:a,fetchTxHex:d!==!1}),i=[{address:n,value:o?0:Number(t.getBaseValue("string"))},...c?[{script:c,value:0}]:[]],{inputs:l,outputs:h}=M({chain:J.Zcash,changeAddress:a,feeRate:s,inputs:u,outputs:i,sweep:o});if(!(l&&h))throw new de("toolbox_utxo_insufficient_balance",{assetValue:t,sender:a});let m=ps({consensusBranchId:await vs(),expiryHeight:0,lockTime:0,version:4,versionGroupId:gs.SAPLING}),{tx:f,inputs:y}=Us({compiledMemo:c,inputs:l,outputs:h,sender:a,tx:m});return{inputs:y,outputs:h,tx:f}}function Un(e={}){let t="scriptType"in e?e.scriptType:void 0,n=xs(e).with({signer:Ut.not(Ut.nullish)},({signer:c})=>c).with({phrase:Ut.string},({phrase:c,derivationPath:u,index:i=0})=>{let{derivationPath:l}=$e({chain:J.Zcash,derivationPath:u,index:i,scriptType:t}),h=cs(l);return Ps({derivationPath:h,phrase:c})}).otherwise(()=>{return}),r=ce({chain:J.Zcash,scriptType:t,signer:n});async function s(c){if(!n)throw new de("toolbox_utxo_no_signer");return await n.signTransaction(c)}async function a(c){let u=await s(c);return r.broadcastTx(u.toHex())}async function d({recipient:c,assetValue:u,feeOptionKey:i=ds.Fast,sweep:l,...h}){let m=await n?.getAddress();if(!(n&&m))throw new de("toolbox_utxo_no_signer");let f=h.feeRate||(await r.getFeeRates())[i],{tx:y}=await xn({...h,assetValue:u,feeRate:f,recipient:c,sender:m,sweep:l}),S=(await n.signTransaction(y)).toHex();return r.broadcastTx(S)}function o({phrase:c,derivationPath:u="m/44'/133'/0'/0/0"}){let i=wn(c),h=bn.fromMasterSeed(i).derive(u);if(!h.privateKey||!h.publicKey)throw new de("toolbox_utxo_invalid_params");return{privateKey:h.privateKey,publicKey:h.publicKey}}function p({phrase:c,derivationPath:u="m/44'/133'/0'/0/0"}){let i=o({derivationPath:u,phrase:c}),l=U(J.Zcash);return Ts(l).encode(i.privateKey)}return{...r,createKeysForPath:o,createTransaction:xn,getPrivateKeyFromMnemonic:p,signAndBroadcastTransaction:a,signTransaction:s,transfer:d,validateAddress:wt}}import{hex as _s}from"@scure/base";import{HDKey as As}from"@scure/bip32";import{derivationPathToString as Os,NetworkDerivationPath as Ss,updateDerivationPath as Cs}from"@swapkit/helpers";function Xs({xpub:e,chain:t,count:n,startIndex:r=0,accountIndex:s,purpose:a,scriptType:d}){if(z("count",n),n<1)throw RangeError("count must be at least 1");z("startIndex",r),Le(t,d),dt({chain:t,purpose:a,scriptType:d});let o=U(t),p=As.fromExtendedKey(e,o.bip32),c=a===void 0?void 0:Cs(Ss[t],{purpose:a}),u=te({accountIndex:s,chain:t,derivationPath:c}),i=pe(u),l=[];for(let h of[!1,!0]){let m=p.deriveChild(Number(h));for(let f=0;f<n;f++){let y=r+f,b=m.deriveChild(y);if(!b.publicKey)continue;let S=Ae({accountIndex:s,chain:t,change:h,derivationPath:c,index:y});l.push({accountIndex:i,address:De({chain:t,network:o,publicKey:b.publicKey,scriptType:d}),change:h,index:y,pubkey:_s.encode(b.publicKey),...a===void 0?{}:{path:Os(S)}})}}return l}function ga(e,t){switch(e){case we.BitcoinCash:return mn(t||{});case we.Zcash:return Un(t);case we.Bitcoin:case we.Dogecoin:case we.Litecoin:case we.Dash:return ce({chain:e,...t});default:throw new Bs("toolbox_utxo_not_supported",{chain:e})}}export{qt as InputSizes,ho as MIN_TX_FEE,Cr as OP_RETURN_OVERHEAD,lt as OutputSizes,Sr as SEGWIT_MARKER_FLAG_WEIGHT,ht as TX_OVERHEAD,oe as UTXOScriptType,Dt as UtxoNetwork,M as accumulative,ie as addInputsAndOutputs,dn as addressFromKeysGetter,z as assertDerivationIndex,ge as calculateTxSize,E as compileMemo,mn as createBCHToolbox,Hs as createCustomUtxoApi,Xn as createHDWalletHelpers,ce as createUTXOToolbox,Un as createZcashToolbox,Xs as deriveAddressesFromXpub,Vs as detectAddressNetwork,Se as getBchAddressType,ke as getDustThreshold,Be as getInputScriptType,se as getInputSize,bt as getMissingSpendingMetadata,U as getNetworkForChain,je as getOutputSize,Xr as getOutputSizeForAddress,Ye as getScriptTypeForAddress,pe as getUTXOAccountIndexFromPath,te as getUTXOAccountPath,Ae as getUTXOAddressPath,cn as getUTXOAddressValidator,Y as getUtxoAddressType,A as getUtxoApi,Rs as getUtxoNetwork,ga as getUtxoToolbox,Tt as getWitnessOverhead,Gr as getZcashAddressType,ft as isSegwitScriptType,$s as isValidAddress,Zt as nonSegwitChains,W as stripPrefix,et as stripToCashAddress,Me as toCashAddress,G as toLegacyAddress,Ne as tryDecodeAddress,Ie as validateBchAddress,tn as validateUtxoAddress,wt as validateZcashAddress};
1
+ import{ia as Ct,ja as tr}from"../../chunk-qk8kg62t.js";import"../../chunk-pz8xe0qj.js";import{NetworkDerivationPath as Kr}from"@swapkit/helpers";function z(e,t){if(!Number.isInteger(t)||t<0)throw RangeError(`${e} must be a non-negative integer, got: ${t}`)}function re({accountIndex:e,chain:t,derivationPath:r}){if(e!==void 0)z("accountIndex",e);let[n,o,s]=r??Kr[t];return[n,o,e??s]}function Oe({accountIndex:e,change:t=!1,chain:r,derivationPath:n,index:o}){return z("index",o),[...re({accountIndex:e,chain:r,derivationPath:n}),Number(t),o]}function pe(e){return e[2]??0}function Fr({deriveAddress:e,getBalance:t,getUtxos:r}){async function n(i){let{accountIndex:p,count:c,startIndex:u=0,change:a=!1}=i;if(z("count",c),c<1)throw RangeError("count must be at least 1");z("startIndex",u);let l=[];for(let h=0;h<c;h++){let m=await e({accountIndex:p,change:a,index:u+h});if(m)l.push(m)}return l}async function o(i){let{gapLimit:p=20,change:c=!1}=i??{},u=[],a=0,l=0;while(a<p){let h=await e({change:c,index:l});if(!h)break;if((await t(h.address)).some((y)=>y.getValue("number")>0))u.push(h),a=0;else a++;l++}return u}async function s(i=20){let[p,c]=await Promise.all([o({change:!1,gapLimit:i}),o({change:!0,gapLimit:i})]),u=[...p,...c],a=await Promise.all(u.map(async(h)=>{let f=(await t(h.address)).reduce((y,b)=>y+b.getValue("number"),0);return{...h,balance:f}})),l=a.reduce((h,m)=>h+m.balance,0);return{addresses:a,total:l}}async function d(i=20){let[p,c]=await Promise.all([o({change:!1,gapLimit:i}),o({change:!0,gapLimit:i})]),u=[...p,...c];return(await Promise.all(u.map(async(l)=>(await r(l.address)).map((m)=>({...m,address:l.address,derivationIndex:l.index,isChange:l.change}))))).flat()}return{deriveAddresses:n,getAggregatedBalance:s,getAggregatedUtxos:d,scanForAddresses:o}}import{Chain as C,getRPCUrl as Dr,RequestClient as Re,SKConfig as Ir,SwapKitError as R,warnOnce as Hr}from"@swapkit/helpers";import{NETWORKS as le}from"@swapkit/utxo-signer";async function Rr({chain:e,txHash:t}){let r=`${he(e)}/push/transaction`,n=JSON.stringify({data:t});try{let o=await Re.post(r,{body:n,headers:{"Content-Type":"application/json"}});if(o.context.code!==200)throw new R("toolbox_utxo_broadcast_failed",{error:o.context.error||"Transaction broadcast failed"});return o.data?.transaction_hash||t}catch(o){let s=await Dr(e);if(s){let d=JSON.stringify({id:Ct(),jsonrpc:"2.0",method:"sendrawtransaction",params:[t]}),i=await Re.post(s,{body:d,headers:{"Content-Type":"application/json"}});if(i.error)throw new R("toolbox_utxo_broadcast_failed",{error:i.error?.message});if(i.result.includes('"code":-26'))throw new R("toolbox_utxo_invalid_transaction",{error:"Transaction amount was too low"});return i.result}throw o}}function he(e){return`https://api.blockchair.com/${Er(e)}`}function Ot(e){switch(e){case C.Bitcoin:return 5;case C.Dogecoin:return 1e4;case C.Litecoin:return 1;case C.Zcash:return 1;default:return 2}}function Er(e){switch(e){case C.BitcoinCash:return"bitcoin-cash";case C.Litecoin:return"litecoin";case C.Dash:return"dash";case C.Dogecoin:return"dogecoin";case C.Zcash:return"zcash";case C.Polkadot:return"polkadot";default:return"bitcoin"}}async function Mr(e){try{let{feePerKb:t}=await Re.get(`https://app.bitgo.com/api/v2/${e.toLowerCase()}/tx/fee`),r=t/1000;return Math.max(r,Ot(e))}catch{return Ot(e)}}async function Se(e,t){let r=await Re.get(`${e}${t?`${e.includes("?")?"&":"?"}key=${t}`:""}`);if(!r||r.context.code!==200)throw new R("toolbox_utxo_api_error",{error:`Failed to query ${e}`});return r.data}async function Nr({chain:e,apiKey:t}){let r=await Se(`${he(e)}/stats`,t);if(typeof r.best_block_height!=="number")throw new R("toolbox_utxo_api_error",{error:"Missing best_block_height in stats response"});return r.best_block_height}async function Xt({address:e,chain:t,apiKey:r}){if(!e)throw new R("toolbox_utxo_invalid_params",{error:"Address is required"});try{return(await Se(`${he(t)}/dashboards/address/${e}?transaction_details=true`,r))[e]}catch{return{address:{balance:0,transaction_count:0},utxo:[]}}}async function Zr({address:e,chain:t,apiKey:r}){return(await Xt({address:e,apiKey:r,chain:t}))?.address.balance||0}async function Bt({chain:e,apiKey:t,txHash:r}){if(!r)throw new R("toolbox_utxo_invalid_params",{error:"TxHash is required"});try{return(await Se(`${he(e)}/raw/transaction/${r}`,t))?.[r]?.raw_transaction||""}catch(n){let o=n instanceof Error?n.message:String(n);return console.error(`Failed to fetch raw transaction: ${o}`),""}}var zr=4294967294;async function Wr({chain:e,apiKey:t,txHash:r}){if(!r)throw new R("toolbox_utxo_invalid_params",{error:"TxHash is required"});let o=(await Se(`${he(e)}/dashboards/transaction/${r}`,t))?.[r];if(!o)throw new R("toolbox_utxo_tx_not_found",{txHash:r});let{transaction:s,inputs:d,outputs:i}=o,p=d.map((u)=>u.spending_sequence),c=s.is_rbf===!0||p.some((u)=>u<zr);return{blockId:s.block_id,confirmed:s.block_id!==-1,fee:s.fee,inputs:d,isRBF:c,outputs:i,sequences:p,size:s.size,txid:s.hash,weight:s.weight}}async function $r({chain:e,address:t,apiKey:r,offset:n=0,limit:o=30}){return(await Se(`${he(e)}/outputs?q=recipient(${t}),is_spent(false)&s=value(desc)&fields=is_spent,transaction_hash,index,value,script_hex,block_id,spending_signature_hex&limit=${o}&offset=${n}`,r)).map(({is_spent:p,script_hex:c,block_id:u,transaction_hash:a,index:l,value:h,spending_signature_hex:m})=>({hash:a,index:l,is_confirmed:u!==-1,is_spent:p,script_hex:c,txHex:m,value:h}))}function Lr(e){return e.reduce((t,r)=>t+r.value,0)}function St(e,t){let r=[...e].sort((n,o)=>o.value-n.value);if(t){let n=[],o=0;for(let s of r)if(n.push(s),o+=s.value,o>=t)break;return n}return r}async function kt({chain:e,address:t,apiKey:r,targetValue:n,accumulativeValue:o=0,offset:s=0,limit:d=30}){if(!t)throw new R("toolbox_utxo_invalid_params",{error:"Address is required"});try{let i=await $r({address:t,apiKey:r,chain:e,limit:d,offset:s,targetValue:n}),c=i.length<d,u=i.filter(({is_spent:y})=>!y),a=Lr(u),l=o+a,h=n&&l>=n;if(c||h)return St(u,n);let m=await kt({accumulativeValue:l,address:t,apiKey:r,chain:e,limit:d,offset:s+d,targetValue:n}),f=[...u,...m];return St(f,n)}catch(i){let p=i instanceof Error?i.message:String(i);return console.error(`Failed to fetch unspent UTXOs: ${p}`),[]}}async function Vr({address:e,chain:t,apiKey:r,fetchTxHex:n=!0,targetValue:o}){let s=await kt({address:e,apiKey:r,chain:t,targetValue:o}),d=n?await Promise.all(s.map(({hash:i})=>Bt({apiKey:r,chain:t,txHash:i}))):[];return s.map(({hash:i,index:p,script_hex:c,value:u},a)=>({address:e,hash:i,index:p,txHex:n?d[a]:void 0,value:u,witnessUtxo:{script:Buffer.from(c,"hex"),value:u}}))}function A(e){let t=Ir.get("apiKeys").blockchair||"";return Hr({condition:!t,id:"no_blockchair_api_key_warning",warning:"No Blockchair API key found. Functionality will be limited."}),{broadcastTx:(r)=>Rr({chain:e,txHash:r}),getAddressData:(r)=>Xt({address:r,apiKey:t,chain:e}),getBalance:(r)=>Zr({address:r,apiKey:t,chain:e}),getBlockHeight:()=>Nr({apiKey:t,chain:e}),getRawTx:(r)=>Bt({apiKey:t,chain:e,txHash:r}),getSuggestedTxFee:()=>Mr(e),getTransactionDetails:(r)=>Wr({apiKey:t,chain:e,txHash:r}),getUtxos:(r)=>Vr({...r,apiKey:t,chain:e})}}function Yo(e){return e}function Go(){return function(t){switch(t){case C.Bitcoin:return le.bitcoin;case C.BitcoinCash:return le.bitcoinCash;case C.Dash:return le.dash;case C.Litecoin:return le.litecoin;case C.Dogecoin:return le.dogecoin;case C.Zcash:return le.zcash;default:throw new R("toolbox_utxo_not_supported",{chain:t})}}}import{sha256 as en}from"@noble/hashes/sha2.js";import{createBase58check as tn}from"@scure/base";import{SwapKitError as Ft}from"@swapkit/helpers";import{CashAddrType as Ee,decodeCashAddr as qr,encodeCashAddr as Yr}from"@swapkit/utxo-signer";var Gr={P2PKH:Ee.P2PKH,P2SH:Ee.P2SH},jr={[Ee.P2PKH]:"P2PKH",[Ee.P2SH]:"P2SH"};function Jr(e,t,r){return Yr({hash:r,prefix:e,type:Gr[t]})}function Qr(e){let t=qr(e),r=jr[t.type];if(!r)throw Error(`Unknown CashAddr type: ${t.type}`);return{hash:t.hash,prefix:t.prefix,type:r}}var st={decode:Qr,encode:Jr};var Dt=tn(en);var It;((r)=>{r.Mainnet="mainnet";r.Testnet="testnet"})(It||={});var ne={["legacy"]:{["mainnet"]:{["p2pkh"]:0,["p2sh"]:5},["testnet"]:{["p2pkh"]:111,["p2sh"]:196}},["bitpay"]:{["mainnet"]:{["p2pkh"]:28,["p2sh"]:40},["testnet"]:{["p2pkh"]:111,["p2sh"]:196}}},rn={["p2pkh"]:"pkh",["p2sh"]:"sh"};function os(e){return Ne(e)!==void 0}function ss(e){return it(e).network}function G(e){let t=it(e);if(t.format==="legacy")return e;return sn(t)}function Me(e){let t=it(e);return an(t)}function Ne(e){if(typeof e!=="string")return;let t=nn(e)??on(e);return t&&{...t,scriptType:rn[t.type]}}function it(e){let t=Ne(e);if(!t)throw new Ft("toolbox_utxo_invalid_address",{address:e});return t}function nn(e){try{let t=Dt.decode(e);if(t.length!==21)throw new Ft("toolbox_utxo_invalid_address",{address:e});let r=t[0],n=Array.prototype.slice.call(t,1);switch(r){case ne.legacy.mainnet.p2pkh:return{format:"legacy",hash:n,network:"mainnet",type:"p2pkh"};case ne.legacy.mainnet.p2sh:return{format:"legacy",hash:n,network:"mainnet",type:"p2sh"};case ne.legacy.testnet.p2pkh:return{format:"legacy",hash:n,network:"testnet",type:"p2pkh"};case ne.legacy.testnet.p2sh:return{format:"legacy",hash:n,network:"testnet",type:"p2sh"};case ne.bitpay.mainnet.p2pkh:return{format:"bitpay",hash:n,network:"mainnet",type:"p2pkh"};case ne.bitpay.mainnet.p2sh:return{format:"bitpay",hash:n,network:"mainnet",type:"p2sh"};default:return}}catch{return}}function on(e){if(e.indexOf(":")!==-1)try{return Kt(e)}catch{}else{let t=["bitcoincash","bchtest","bchreg"];for(let r of t)try{return Kt(`${r}:${e}`)}catch{}}return}function Kt(e){try{let{hash:t,prefix:r,type:n}=st.decode(e);return{format:"cashaddr",hash:Array.prototype.slice.call(t,0),network:r==="bitcoincash"?"mainnet":"testnet",type:n==="P2PKH"?"p2pkh":"p2sh"}}catch{return}}function sn(e){let t=ne.legacy[e.network][e.type],r=Buffer.alloc(1+e.hash.length);return r[0]=t,r.set(e.hash,1),Dt.encode(r)}function an(e){let t=e.network==="mainnet"?"bitcoincash":"bchtest",r=e.type==="p2pkh"?"P2PKH":"P2SH",n=new Uint8Array(e.hash);return st.encode(t,r,n)}import{Chain as ae,SwapKitError as mt}from"@swapkit/helpers";import{SwapKitError as qe,UTXO_SCRIPT_TYPE_LIST as Bn,UTXO_SCRIPT_TYPES as Vt,UTXOScriptType as Ye}from"@swapkit/helpers";import{Script as kn}from"@swapkit/utxo-signer";import{Chain as at}from"@swapkit/helpers";import{getAddressScriptType as dn,getTransparentZcashAddressType as un,getZcashAddressType as pn}from"@swapkit/utxo-signer";import{match as ln}from"ts-pattern";import{Chain as fe}from"@swapkit/helpers";import{NETWORKS as Te}from"@swapkit/utxo-signer";import{match as cn}from"ts-pattern";function U(e){return cn(e).with(fe.Bitcoin,()=>Te.bitcoin).with(fe.BitcoinCash,()=>Te.bitcoinCash).with(fe.Dash,()=>Te.dash).with(fe.Dogecoin,()=>Te.dogecoin).with(fe.Litecoin,()=>Te.litecoin).with(fe.Zcash,()=>Te.zcash).exhaustive()}function W(e){return e.replace(/(bchtest:|bitcoincash:)/,"")}function Ce(e){if(typeof e!=="string")return null;let t=Ne(W(e));if(!t||t.network!=="mainnet")return null;return t.scriptType}var hn=["sprout","sapling","unified"];function fn(e){let t=un(e,U(at.Zcash));if(t)return t;let r=pn(e);return r&&hn.includes(r)?r:null}function j({address:e,chain:t}){return ln(t).with(at.BitcoinCash,()=>Ce(e)).with(at.Zcash,()=>fn(e)).otherwise(()=>dn(e,U(t)))}import{Chain as oe,derivationPathToString as Ht,getPurposeFromPath as Tn,getUTXOScriptTypeForPath as Rt,getUTXOScriptTypeForPurpose as Nt,resolveDerivationPath as mn,SwapKitError as Xe,UTXO_SCRIPT_TYPE_LIST as Et,UTXO_SCRIPT_TYPES as me,UTXOChains as yn,UTXOScriptType as O,updateDerivationPath as gn,warnOnce as xn}from"@swapkit/helpers";import{CashAddrPrefix as bn,CashAddrType as wn,encodeCashAddr as Pn,OutScript as Zt,p2pkh as Un,p2sh as _n,p2tr as vn,p2wpkh as Mt}from"@swapkit/utxo-signer";var Ze=Object.freeze([O.P2PKH]),An=Object.freeze({[oe.Bitcoin]:Et,[oe.BitcoinCash]:Ze,[oe.Dash]:Ze,[oe.Dogecoin]:Ze,[oe.Litecoin]:Et,[oe.Zcash]:Ze});function We(e){return An[e]}function ct(e){return We(e).some((t)=>me[t].witness)}function ye(e,t){return We(e).includes(t)}function $e(e,t){if(ye(e,t))return t;throw new Xe("toolbox_utxo_unsupported_script_type",{chain:e,error:`${e} cannot encode ${t}; supported: ${We(e).join(", ")}`,scriptType:t,supported:We(e)})}var zt=yn.filter((e)=>!ct(e));function On({purpose:e,scriptType:t}){let r=Nt(e);return r===void 0||r===t}function dt({chain:e,purpose:t,scriptType:r}){xn({condition:!On({purpose:t,scriptType:r}),id:`utxo_off_standard_encoding_${e}_${t}_${r}`,warning:`${e}: encoding m/${t}' keys as ${r}, not the ${Nt(t)} the path implies. No other wallet derives these addresses: move funds out of them, never receive into them.`})}function Le({chain:e,derivationPath:t,index:r=0,scriptType:n}){if(t){if(!n){let i=Rt(t);throw new Xe("toolbox_utxo_invalid_params",{chain:e,derivationPath:Ht(t),error:`scriptType is required alongside derivationPath: getUTXOScriptTypeForPath gives the standard one${i?` (${i})`:""}, or state another deliberately.`})}return $e(e,n),dt({chain:e,purpose:Tn(t),scriptType:n}),{derivationPath:t,scriptType:n}}let o=mn({chain:e,index:r}),s=n?gn(o,{purpose:me[n].purpose}):o,d=n??Rt(s);if(!d)throw new Xe("toolbox_utxo_invalid_params",{chain:e,derivationPath:Ht(s),error:`${e}: the default derivation path has no standard script type`});return $e(e,d),{derivationPath:s,scriptType:d}}function Sn(e){return e.length===32?e:e.slice(1)}function ze(e,t){if(!e.address)throw new Xe("toolbox_utxo_invalid_address",{error:`Could not derive a ${t} address`});return e}var Cn={[O.P2PKH]:(e,t)=>{let{address:r,script:n}=ze(Un(e,t),O.P2PKH);return{address:r,script:n}},[O.P2SH_P2WPKH]:(e,t)=>{let r=Mt(e,t),{address:n,script:o}=ze(_n(r,t),O.P2SH_P2WPKH);return{address:n,redeemScript:r.script,script:o}},[O.P2WPKH]:(e,t)=>{let{address:r,script:n}=ze(Mt(e,t),O.P2WPKH);return{address:r,script:n}},[O.P2TR]:(e,t)=>{let r=Sn(e),{address:n,script:o}=ze(vn(r,void 0,t),O.P2TR);return{address:n,script:o,tapInternalKey:r}}};function Ve(e,t,r){return Cn[e](t,r)}function ut(e,t){if(e!==oe.BitcoinCash)return t.address;let r=Zt.decode(t.script);if(r.type!=="pkh")throw new Xe("toolbox_utxo_invalid_address",{chain:e,error:`Cannot encode ${r.type} as CashAddr`});return Pn({hash:r.hash,prefix:bn.MAINNET,type:wn.P2PKH}).replace(/^bitcoincash:/,"")}var Xn=Object.freeze({pkh:O.P2PKH,sh:O.P2SH_P2WPKH,tr:O.P2TR,wpkh:O.P2WPKH}),Wt=Object.freeze({pkh:me[O.P2PKH].outputSize,sh:me[O.P2SH_P2WPKH].outputSize,tr:me[O.P2TR].outputSize,wpkh:me[O.P2WPKH].outputSize,wsh:43});function $t(e){return e in Wt}function Lt(e){return $t(e)?Wt[e]:void 0}function Be(e){return Xn[e]}function pt(e){try{let{type:t}=Zt.decode(e);return $t(t)?Be(t):void 0}catch{return}}import{UTXOScriptType as ie}from"@swapkit/helpers";var _s=1000,ht=10,Kn=2,Fn=10;function E(e){let t=new Uint8Array(Buffer.from(e,"utf8"));return kn.encode(["RETURN",t])}function qt(e){return Object.fromEntries(Bn.map((t)=>[t,Vt[t][e]]))}var Yt=qt("inputSize"),lt=qt("outputSize"),ft=(e)=>Vt[e].witness,Ge=(e,t)=>{let r=j({address:e,chain:t});if(!r)throw new qe("toolbox_utxo_invalid_address",{address:e,chain:t});let n=Be(r);if(!n||!ye(t,n))throw new qe("toolbox_utxo_unsupported_script_type",{address:e,addressType:r,chain:t,error:"Address is valid but its script type is not one the SDK spends from"});return n},Dn=(e,t)=>{let r=j({address:e,chain:t});if(!r)throw new qe("toolbox_utxo_invalid_address",{address:e,chain:t});let n=Lt(r);if(!n)throw new qe("toolbox_utxo_unsupported_script_type",{address:e,addressType:r,chain:t,error:"Address is valid but a transparent transaction cannot pay to it"});return n},ge=({chain:e,inputs:t,outputs:r,feeRate:n})=>{let o=t[0]?ke(t[0],e):Ye.P2PKH,s=n?t.filter((u)=>u.value>=Yt["type"in u&&u.type?u.type:Ye.P2PKH]*Math.ceil(n)):t,d=0,i=0;for(let u of s)if(d+=se(u,e),!ft(ke(u,e)))i++;let p=r?.reduce((u,a)=>u+je(a,e),0)||lt[o],c=i<s.length;return ht+d+p+Tt(c,i)},ke=(e,t)=>{if("type"in e&&e.type)return e.type;if("address"in e&&e.address)return Ge(e.address,t);return Ye.P2PKH},se=(e,t)=>Yt[ke(e,t)],Tt=(e,t)=>e?Math.ceil((Kn+t)/4):0,je=(e,t,r)=>{if(e?.script)return Fn+e.script.length+(e.script.length>=74?2:1);if(r)return lt[r];if("address"in e&&e.address)return Dn(e.address,t);return lt[Ye.P2PKH]};function Ke(e){switch(e){case ae.Bitcoin:case ae.BitcoinCash:return 550;case ae.Dash:case ae.Litecoin:return 5500;case ae.Dogecoin:return 1e5;case ae.Zcash:return 546;default:throw new mt("toolbox_utxo_not_supported",{chain:e})}}function M({inputs:e,outputs:t,feeRate:r=1,chain:n=ae.Bitcoin,changeAddress:o="",sweep:s=!1}){let d=Ke(n),i=e.filter((f)=>{let y=se(f,n)*r;return s?f.value>Math.max(y,d):y<=f.value});if(s){let f=Math.ceil(r*ge({chain:n,inputs:i,outputs:t})),y=i.reduce((X,q)=>X+q.value,0),b=y-f;if(b<=d)throw new mt("toolbox_sweep_amount_too_low",{available:y,dustThreshold:d,fee:f});let S=t.findIndex((X)=>("address"in X)&&X.address);if(S===-1)throw new mt("toolbox_utxo_invalid_params",{error:"Sweep requires a recipient output"});return{fee:f,inputs:i,outputs:t.map((X,q)=>q===S?{...X,value:b}:X)}}let p=ht+t.reduce((f,y)=>f+je(y,n),0),c=t.reduce((f,y)=>f+y.value,0),u=0,a=0,l=!1,h=0,m=[];for(let f of i){if(u+=se(f,n),ft(ke(f,n)))l=!0;else a++;h+=f.value,m.push(f);let y=(p+u+Tt(l,a))*r,b=y+c;if(h<b)continue;let S=h-b,X=r*je({address:o,value:0},n);if(S>X){let q=X+y,Ue=h-(c+Math.ceil(q));if(Ue>Math.max(se({value:0},n)*r,Ke(n)))return{fee:Math.ceil(q),inputs:m,outputs:t.concat({address:o,value:Ue})}}return{fee:Math.ceil(y),inputs:m,outputs:t}}return{fee:Math.ceil(r*ge({chain:n,inputs:e,outputs:t}))}}import{secp256k1 as In}from"@noble/curves/secp256k1.js";import{base64 as Hn,utf8 as Gt}from"@scure/base";import{SwapKitError as Rn,UTXOScriptType as yt}from"@swapkit/helpers";import{CompactSize as En,utils as Mn}from"@swapkit/utxo-signer";var Nn=Gt.decode(`\x18Bitcoin Signed Message:
2
+ `),jt={[yt.P2PKH]:31,[yt.P2SH_P2WPKH]:35,[yt.P2WPKH]:39};function Zn(e){return jt[e]!==void 0}function zn(e){let t=Gt.decode(e);return Mn.sha256x2(Nn,En.encode(BigInt(t.length)),t)}function Jt({message:e,privateKey:t,scriptType:r}){let n=jt[r];if(n===void 0)throw new Rn("toolbox_utxo_unsupported_script_type",{error:`BIP-137 message signatures cannot express a ${r} address`,scriptType:r});let o=In.sign(zn(e),t,{format:"recovered",prehash:!1}),[s=0]=o,d=new Uint8Array(65);return d[0]=n+s,d.set(o.subarray(1),1),Hn.encode(d)}import{Chain as Pe,SwapKitError as zo}from"@swapkit/helpers";import{hex as hr}from"@scure/base";import{Chain as uo,derivationPathToString as po,FeeOption as lo,resolveDerivationPath as ho,SwapKitError as L}from"@swapkit/helpers";import{BCHSigHash as fo,CashAddrPrefix as fr,CashAddrType as Tr,encodeCashAddr as mr,NETWORKS as To,p2pkh as yr,Transaction as gr}from"@swapkit/utxo-signer";import{secp256k1 as Wn}from"@noble/curves/secp256k1.js";import{hex as J}from"@scure/base";import{HDKey as rr}from"@scure/bip32";import{mnemonicToSeedSync as bt}from"@scure/bip39";import{AssetValue as gt,applyFeeMultiplier as Qt,Chain as be,derivationPathToString as Fe,FeeOption as N,NetworkDerivationPath as $n,SwapKitError as P,SwapKitNumber as Ln,UTXO_SCRIPT_TYPES as Vn,warnOnce as qn}from"@swapkit/helpers";import{BCHSigHash as nr,RBF_SEQUENCE as Yn,SigHash as er,Transaction as Je,utils as Gn,WIF as or}from"@swapkit/utxo-signer";var Qe=[be.Bitcoin];function sr({address:e,chain:t}){return j({address:e,chain:t})!==null}function jn({phrase:e,derivationPath:t,network:r,seed:n}){let o=n??bt(e),d=rr.fromMasterSeed(o,r.bip32).derive(t);if(!d.privateKey)throw new P("toolbox_utxo_invalid_params",{error:"Could not derive private key from phrase"});return d.privateKey}function xt(e){return Wn.getPublicKey(e,!0)}function De({publicKey:e,chain:t,network:r,scriptType:n}){return ut(t,Ve(n,e,r))}function xe({phrase:e,derivationPath:t,chain:r,wif:n,seed:o}){let s=U(r);if(n){let c=or(s).decode(n),u=xt(c);return{privateKey:c,publicKey:u}}if(!e)throw new P("toolbox_utxo_invalid_params",{error:"Either phrase or wif must be provided"});let d=t||Fe($n[r]),i=jn({derivationPath:d,network:s,phrase:e,seed:o}),p=xt(i);return{privateKey:i,publicKey:p}}function Jn(e,t){return or(U(t)).encode(e)}function Qn({phrase:e,derivationPath:t,chain:r,seed:n}){let o=t.split("/");if(o.length<4)throw new P("toolbox_utxo_invalid_params",{error:`Derivation path must have at least 4 levels (got ${o.length}): ${t}`});let s=U(r),d=n??bt(e),i=rr.fromMasterSeed(d,s.bip32),p=o.slice(0,4).join("/");return i.derive(p)}function eo(e,t){if(!e||!Vn[e].witness)return!1;return e!==ie.P2SH_P2WPKH||!!t}function ir({chain:e,script:t,publicKey:r,network:n}){let o=pt(t);if(o!==ie.P2SH_P2WPKH&&o!==ie.P2TR)return{};if(!ye(e,o))return{};let s=Ve(o,r,n);if(Gn.compareBytes(s.script,t)!==0)return{};return o===ie.P2TR?{tapInternalKey:s.tapInternalKey}:{redeemScript:s.redeemScript}}function to(e,t,r){if(!r)return!1;let n=j({address:e,chain:t}),o=n?Be(n):void 0;if(!o||!ye(t,o))return!1;let s=ut(t,Ve(o,r,U(t)));return t===be.BitcoinCash?W(s)===W(e):s===e}function ro(e){return e.witnessUtxo?.script??e.nonWitnessUtxo?.outputs[e.index??0]?.script}function wt({chain:e,tx:t,publicKey:r,network:n,indexes:o}){let s=o??Array.from({length:t.inputsLength},(i,p)=>p),d=[];for(let i of s){let p=t.getInput(i),c=ro(p);if(!c)continue;let{redeemScript:u,tapInternalKey:a}=ir({chain:e,network:n,publicKey:r,script:c}),l={index:i};if(u&&!p.redeemScript)l.redeemScript=u;if(a&&!p.tapInternalKey)l.tapInternalKey=a;if(l.redeemScript||l.tapInternalKey)d.push(l)}return d}function ce({inputs:e,outputs:t,chain:r,tx:n,sender:o,compiledMemo:s,enableRBF:d=!1}){let i=U(r),p=ct(r),c=d?Yn:void 0,u=new Set;for(let a of e){let l=`${a.hash}:${a.index}`;if(u.has(l))throw new P("toolbox_utxo_invalid_params",{error:"Duplicate input detected"});u.add(l);let h=typeof a.hash==="string"?J.decode(a.hash):a.hash,m=a.witnessUtxo?pt(a.witnessUtxo.script):void 0,f=a.publicKey&&a.witnessUtxo?ir({chain:r,network:i,publicKey:a.publicKey,script:a.witnessUtxo.script}):{};if(p&&a.witnessUtxo&&eo(m,f.redeemScript))n.addInput({...f,index:a.index,sequence:c,txid:h,witnessUtxo:{amount:BigInt(a.witnessUtxo.value),script:a.witnessUtxo.script}});else if(a.txHex)n.addInput({...f,index:a.index,nonWitnessUtxo:J.decode(a.txHex),sequence:c,txid:h,...r===be.BitcoinCash?{sighashType:nr.ALL}:{}});else throw new P("toolbox_utxo_invalid_params",{error:`Input ${l} cannot be signed from its witnessUtxo alone: it needs its previous transaction (txHex), or — if it is a nested-segwit output — the public key that controls it, which its redeemScript derives from`})}for(let a of t){let l="address"in a&&a.address?a.address:o;if(r===be.BitcoinCash)l=G(l);if(a.script)if(s)n.addOutput({amount:0n,script:s});else throw new P("toolbox_utxo_invalid_params",{error:"An output carrying a script needs the compiled memo it carries"});else n.addOutputAddress(l,BigInt(a.value),i)}return{inputs:e,tx:n}}async function we(e){let t=await A(e).getSuggestedTxFee();return{[N.Average]:t,[N.Fast]:Qt(t,N.Fast),[N.Fastest]:Qt(t,N.Fastest)}}async function ar({assetValue:e,recipient:t,memo:r,sender:n,sweep:o,fetchTxHex:s=!1,publicKey:d},i,{forEstimateOnly:p=!1}={}){let c=e.chain,u=Ge(n,c),a=u===ie.P2PKH||u===ie.P2SH_P2WPKH&&!to(n,c,d),l=s||!p&&a,h=e.getBaseValue("number"),m=o?void 0:i??(await we(c))[N.Fastest],f=o||m===void 0?void 0:Math.ceil(h+m*5000);return{inputs:await A(c).getUtxos({address:n,fetchTxHex:l,targetValue:f}),outputs:[{address:t,value:o?0:h},...r?[{address:"",script:E(r),value:0}]:[]]}}async function cr({assetValue:e,recipient:t,memo:r,feeRate:n,sender:o,fetchTxHex:s=!1,enableRBF:d=!1,sweep:i,publicKey:p}){let c=e.chain,u=r?E(r):null,a=await ar({assetValue:e,fetchTxHex:s,memo:r,publicKey:p,recipient:t,sender:o,sweep:i},n),{inputs:l,outputs:h}=M({...a,chain:c,changeAddress:o,feeRate:n,sweep:i});if(!(l&&h))throw new P("toolbox_utxo_insufficient_balance",{assetValue:e,sender:o});let m=p?l.map((S)=>({...S,publicKey:p})):l,f=new Je({allowUnknownOutputs:!!u,version:1}),{inputs:y,tx:b}=ce({chain:c,compiledMemo:u,enableRBF:d,inputs:m,outputs:h,sender:o,tx:f});return{inputs:y,tx:b,utxos:a.inputs}}async function dr({assetValue:e,feeOptionKey:t=N.Fast,feeRate:r,memo:n,sender:o,recipient:s,sweep:d}){let i=e.chain,p,c;if(r!==void 0)p=r,c=Math.floor(r);else{let a=await we(i);p=a[N.Fastest],c=a[t]}let u=await ar({assetValue:e,memo:n,recipient:s,sender:o,sweep:d},p,{forEstimateOnly:!0});return M({...u,chain:i,changeAddress:o,feeRate:c,sweep:d})}function no(e){return async function({from:r,memo:n,feeRate:o,feeOptionKey:s=N.Fast,recipient:d=r,recipients:i=1}){let p=o??(await we(e))[s],u=(await A(e).getUtxos({address:r,fetchTxHex:!1})).filter((f)=>f.value>Math.max(Ke(e),se(f,e)*p));if(!u.length)return gt.from({chain:e});let a=typeof i==="number"?Math.max(i,1):i.length,l=typeof i==="number"||a===0?Array.from({length:a||1},()=>({address:d,value:0})):[...i];if(n)l.push({address:r,script:E(n),value:0});let{outputs:h}=M({chain:e,feeRate:p,inputs:u,outputs:l,sweep:!0}),m=h?.[0]?.value??0;return gt.from({chain:e,value:BigInt(m)})}}function oo(e){return async function(r){let{fee:n}=await dr(r);return gt.from({chain:e,value:Ln.fromBigInt(BigInt(n),8).getValue("string")})}}function so({chain:e,phrase:t,derivationPath:r,scriptType:n,seed:o}){let s=U(e),{privateKey:d,publicKey:i}=xe({chain:e,derivationPath:r,phrase:t,seed:o}),p=ur(e);return{getAddress:()=>De({chain:e,network:s,publicKey:i,scriptType:n}),privateKey:d,publicKey:i,signTransaction:(c)=>{for(let{index:u,...a}of wt({chain:e,network:s,publicKey:i,tx:c}))c.updateInput(u,a);return c.sign(d,p),c}}}function ur(e){return e===be.BitcoinCash?[nr.ALL]:[er.ALL,er.DEFAULT]}function io(e,t,r){return async function({memo:o,recipient:s,feeOptionKey:d,feeRate:i,assetValue:p,enableRBF:c=!1,sweep:u}){let a=await t?.getAddress();if(!(t&&a))throw new P("toolbox_utxo_no_signer");if(!s)throw new P("toolbox_utxo_invalid_params",{error:"Recipient address must be provided"});qn({condition:c&&!Qe.includes(e),id:`rbf_not_supported_${e}`,warning:`RBF (Replace-by-Fee) is not reliably supported on ${e}. Transaction will be created without RBF signaling.`});let l=c&&Qe.includes(e),h=i||(await we(e))[d||N.Fast],{tx:m}=await cr({assetValue:p,enableRBF:l,feeRate:h,memo:o,publicKey:r,recipient:s,sender:a,sweep:u}),f=await t.signTransaction(m);return f.finalize(),A(e).broadcastTx(J.encode(f.extract()))}}function pr(e){return(t)=>sr({address:t,chain:e})}function lr(e,{scriptType:t}){let r=U(e);return function(o){if(!o)throw new P("toolbox_utxo_invalid_params",{error:"Keys must be provided"});return De({chain:e,network:r,publicKey:o.publicKey,scriptType:t})}}function ao(e){let t=e?.publicKey;if(t===void 0)return;if(t instanceof Uint8Array&&t.length===33)return t;throw new P("toolbox_utxo_invalid_params",{error:"signer.publicKey must be a 33-byte compressed public key (Uint8Array)"})}function de(e){let{chain:t}=e,r=e.phrase?e:void 0;if(!r&&"derivationPath"in e&&e.derivationPath!==void 0)throw new P("toolbox_utxo_invalid_params",{error:"derivationPath needs a phrase; a toolbox built around a signer uses the signer's addresses"});let n=r?.phrase,o=r?.index??0,s=n?bt(n):void 0,{derivationPath:d,scriptType:i}=Le({chain:t,derivationPath:r?.derivationPath,index:o,scriptType:e.scriptType}),p=Fe(d),c=n?so({chain:t,derivationPath:p,phrase:n,scriptType:i,seed:s}):void 0,u=r?void 0:e.signer,a=c||u,l=n?xe({chain:t,derivationPath:p,phrase:n,seed:s}):void 0,h=l?.publicKey??ao(u);function m(){if(a)return a.getAddress();return Promise.resolve(void 0)}function f(T){if(!n)return;let g=re({accountIndex:T,chain:t,derivationPath:d});return Qn({chain:t,derivationPath:Fe(g),phrase:n,seed:s})}let y=f();function b(){if(!y)return;return y.publicExtendedKey}function S({accountIndex:T}={}){let g=T===void 0?y:f(T);if(!g)return;let w=re({accountIndex:T,chain:t,derivationPath:d});return{accountIndex:pe(w),path:Fe(w),xpub:g.publicExtendedKey}}function X({accountIndex:T,index:g,change:w=!1}){let v=T===void 0?y:f(T);if(!v)return;let x=Oe({accountIndex:T,chain:t,change:w,derivationPath:d,index:g}),K=U(t),I=v.deriveChild(Number(w)).deriveChild(g);if(!I.publicKey)throw new P("toolbox_utxo_invalid_params",{error:"Could not derive public key"});let B=De({chain:t,network:K,publicKey:I.publicKey,scriptType:i}),F=J.encode(I.publicKey);return{accountIndex:pe(x),address:B,change:w,index:g,path:Fe(x),pubkey:F}}async function q(T){if(!Qe.includes(t))return{reason:`RBF is not supported on ${t}`,supported:!1};let g=await A(t).getTransactionDetails(T);return{canReplace:g.isRBF&&!g.confirmed,confirmed:g.confirmed,enabled:g.isRBF,fee:g.fee,sequences:g.sequences,supported:!0}}async function Ue({txid:T,newFeeRate:g,recipient:w,memo:v}){if(!Qe.includes(t))throw new P("toolbox_utxo_rbf_not_supported",{chain:t});let x=await A(t).getTransactionDetails(T);if(!x.isRBF)throw new P("toolbox_utxo_tx_not_replaceable",{txid:T});if(x.confirmed)throw new P("toolbox_utxo_tx_already_confirmed",{blockId:x.blockId,txid:T});let K=x.inputs.reduce((_,D)=>_+D.value,0),B=x.outputs.find((_)=>_.recipient===w)?.value||0;if(B===0)throw new P("toolbox_utxo_invalid_params",{error:"Could not determine send amount from original transaction"});let F=await Promise.all(x.inputs.map(async(_)=>{let D=await A(t).getRawTx(_.transaction_hash),k=Je.fromRaw(J.decode(D),{allowUnknownOutputs:!0,disableScriptCheck:!0}).getOutput(_.index);return{address:_.recipient,hash:_.transaction_hash,index:_.index,publicKey:h,txHex:D,value:_.value,witnessUtxo:k.script&&k.amount!==void 0?{script:Buffer.from(k.script),value:Number(k.amount)}:void 0}})),H=v?E(v):null,ee=K-B-x.fee,_e=await m(),ue=[];if(H)ue.push({address:"",script:H,value:0});if(ee>Ke(t)&&_e)ue.push({address:_e,value:ee});let He=ge({chain:t,inputs:F.map((_)=>({..._,type:Ge(_.address,t)})),outputs:[{address:w,value:B},...ue]}),Y=Math.ceil(He*g);if(Y<=x.fee)throw new P("toolbox_utxo_rbf_fee_too_low",{newFee:Y,originalFee:x.fee});let ve=Y-x.fee,te=B-ve;if(te<=0)throw new P("toolbox_utxo_rbf_insufficient_change");let Ae=new Je({allowUnknownOutputs:!!H,version:1}),rt=[{address:w,value:te},...ue];return ce({chain:t,compiledMemo:H,inputs:F,outputs:rt,sender:_e||w,tx:Ae}),{feeDelta:ve,newFee:Y,originalFee:x.fee,tx:Ae}}async function Or({txid:T,newFeeRate:g,recipient:w,memo:v}){let{tx:x,originalFee:K,newFee:I}=await Ue({memo:v,newFeeRate:g,recipient:w,txid:T}),B=await tt(x);B.finalize();let F=await A(t).broadcastTx(J.encode(B.extract()));return{newFee:I,originalFee:K,txid:F}}function vt({accountIndex:T,index:g,change:w=!1}){z("index",g);let v=T===void 0?y:f(T);if(!v)return;return v.deriveChild(Number(w)).deriveChild(g).privateKey||void 0}function At({tx:T,inputDerivations:g}){if(!y)throw new P("toolbox_utxo_no_signer");let w=ur(t),v=U(t);for(let x=0;x<g.length;x++){let K=g[x];if(!K)continue;let{derivationIndex:I,isChange:B}=K,F=vt({change:B,index:I});if(!F)throw new P("toolbox_utxo_invalid_params",{error:`Could not derive private key for input ${x} at index ${I}`});for(let{index:H,...ee}of wt({chain:t,indexes:[x],network:v,publicKey:xt(F),tx:T}))T.updateInput(H,ee);T.signIdx(F,x,w)}return T}async function Sr({utxos:T,recipient:g,assetValue:w,memo:v,feeRate:x,feeOptionKey:K,changeAddress:I,sweep:B}){if(B)throw new P("toolbox_utxo_invalid_params",{error:"Sweep is not supported for transfers from multiple addresses"});if(!y)throw new P("toolbox_utxo_no_signer");let F=x||(await we(t))[K||N.Fast],H=v?E(v):null,ee=[{address:g,value:w.getBaseValue("number")}];if(H)ee.push({address:"",script:H,value:0});let _e=T.map(({address:_,hash:D,index:k,value:nt,txHex:kr,witnessUtxo:ot})=>({address:_,hash:D,index:k,txHex:kr,value:nt,witnessUtxo:ot?{script:ot.script,value:ot.value}:void 0})),ue=T[0]?.address,He=I||await m()||ue||g,{inputs:Y,outputs:ve}=M({chain:t,changeAddress:He,feeRate:F,inputs:_e,outputs:ee});if(!(Y&&ve))throw new P("toolbox_utxo_insufficient_balance",{assetValue:w,sender:"multiple addresses"});let te=new Je({allowUnknownOutputs:!!H,version:1}),Ae=Y.map((_)=>{let D=T.find((k)=>k.hash===_.hash&&k.index===_.index);return D?{derivationIndex:D.derivationIndex,isChange:D.isChange}:{derivationIndex:0,isChange:!1}}),rt=Y.map((_,D)=>{let k=Ae[D],nt=k?y.deriveChild(Number(k.isChange)).deriveChild(k.derivationIndex).publicKey:null;return{..._,publicKey:nt??void 0}});return ce({chain:t,compiledMemo:H,inputs:rt,outputs:ve,sender:He,tx:te}),At({inputDerivations:Ae,tx:te}),te.finalize(),A(t).broadcastTx(J.encode(te.extract()))}function Cr({address:T,gapLimit:g=20}){if(!y)return;for(let w=0;w<g;w++){let v=X({change:!1,index:w}),x=X({change:!0,index:w}),K=v?.address===T?!1:x?.address===T;if(v?.address===T||x?.address===T)return{change:K,index:w}}return}function tt(T){if(!a)throw new P("toolbox_utxo_no_signer");return a.signTransaction(T)}let Xr=t===be.Bitcoin&&l?async(T)=>Jt({message:T,privateKey:l.privateKey,scriptType:i}):void 0;async function Br(T){let g=await tt(T);return g.finalize(),await A(t).broadcastTx(J.encode(g.extract()))}return{accumulative:M,broadcastTx:(T)=>A(t).broadcastTx(T),bumpFee:Or,calculateTxSize:(T)=>ge({...T,chain:t}),createKeysForPath:(T)=>xe({...T,chain:t}),createReplacementTransaction:Ue,createTransaction:(T)=>cr({publicKey:h,...T}),deriveAddressAtIndex:X,derivePrivateKeyAtIndex:vt,estimateMaxSendableAmount:no(t),estimateTransactionFee:oo(t),getAddress:m,getAddressFromKeys:lr(t,{scriptType:i}),getAddressType:(T)=>j({address:T,chain:t}),getBalance:tr(t),getExtendedPublicKey:b,getExtendedPublicKeyInfo:S,getFeeRates:()=>we(t),getInputsOutputsFee:dr,getNetworkForChain:()=>U(t),getPrivateKeyFromMnemonic:(T)=>Jn(xe({...T,chain:t}).privateKey,t),isRBFEnabled:q,keys:l,resolveDerivationIndex:Cr,scriptType:i,signAndBroadcastTransaction:Br,signMessage:Xr,signTransaction:tt,signTransactionWithMultipleKeys:At,transfer:io(t,a,h),transferFromMultipleAddresses:Sr,validateAddress:pr(t)}}import{getZcashAddressType as co,validateZcashAddress as Pt}from"@swapkit/utxo-signer";function Ie(e){return Ce(e)!==null}var Z=uo.BitcoinCash;function et(e){return W(Me(e))}function mo(e){let t=U(Z);function r(o){return o.sign(e.privateKey,[fo.ALL]),o}function n(){let o=yr(e.publicKey,t);if(!o.hash)throw new L("toolbox_utxo_invalid_address",{error:"Could not derive BCH address hash"});let s=mr({hash:o.hash,prefix:fr.MAINNET,type:Tr.P2PKH});return Promise.resolve(s.replace(/^bitcoincash:/,""))}return{getAddress:n,signTransaction:r}}function xr(e={}){let t="phrase"in e?e.phrase:void 0,r="index"in e?e.index||0:0,n="derivationPath"in e?e.derivationPath:void 0,o=ho({chain:Z,derivationPath:n,index:r}),s=po(o),d=t?xe({chain:Z,derivationPath:s,phrase:t}):void 0,i=d?mo(d):("signer"in e)?e.signer:void 0;function p(){return Promise.resolve(i?.getAddress())}let c="scriptType"in e?e.scriptType:void 0,{getBalance:u,getFeeRates:a,broadcastTx:l,...h}=de(t?{chain:Z,index:r,phrase:t,...n?{derivationPath:n,scriptType:c}:{scriptType:c}}:{chain:Z,scriptType:c});function m(b,S=!0){return u(W(Me(b)))}function f(b){if(!i)throw new L("toolbox_utxo_no_signer");return i.signTransaction(b)}async function y(b){let S=await f(b);return S.finalize(),await l(hr.encode(S.extract()))}return{...h,broadcastTx:l,buildTx:go,createTransaction:br,getAddress:p,getAddressFromKeys:xo,getBalance:m,getFeeRates:a,signAndBroadcastTransaction:y,signTransaction:f,stripPrefix:W,stripToCashAddress:et,transfer:yo({broadcastTx:l,getFeeRates:a,signer:i}),validateAddress:Ie}}async function br({assetValue:e,recipient:t,memo:r,feeRate:n,sender:o,sweep:s}){if(!Ie(t))throw new L("toolbox_utxo_invalid_address",{address:t});let d=Math.ceil(e.getBaseValue("number")+n*7500),i=await A(Z).getUtxos({address:et(o),fetchTxHex:!0,targetValue:s?void 0:d}),p=r?E(r):null,c=[],u=G(t);if(c.push({address:u,value:s?0:e.getBaseValue("number")}),p)c.push({script:p,value:0});let{inputs:a,outputs:l}=M({chain:Z,feeRate:n,inputs:i,outputs:c,sweep:s});if(!(a&&l))throw new L("toolbox_utxo_insufficient_balance",{assetValue:e,sender:o});let h=new gr({allowUnknownOutputs:!!p,version:1}),m=G(o),{inputs:f,tx:y}=ce({chain:Z,compiledMemo:p,inputs:a,outputs:l.map((b)=>("address"in b)&&b.address?{...b,address:G(b.address)}:b),sender:m,tx:h});return{inputs:f,tx:y,utxos:a}}function yo({broadcastTx:e,getFeeRates:t,signer:r}){return async function({recipient:o,assetValue:s,feeOptionKey:d=lo.Fast,sweep:i,...p}){let c=await r?.getAddress();if(!(r&&c))throw new L("toolbox_utxo_no_signer");if(!o)throw new L("toolbox_utxo_invalid_params",{error:"Recipient address must be provided"});let u=p.feeRate||(await t())[d],{tx:a}=await br({...p,assetValue:s,feeRate:u,recipient:o,sender:c,sweep:i}),l=await r.signTransaction(a);return l.finalize(),e(hr.encode(l.extract()))}}async function go({assetValue:e,recipient:t,memo:r,feeRate:n,sender:o}){let s=Me(t);if(!Ie(s))throw new L("toolbox_utxo_invalid_address",{address:s});let d=Math.ceil(e.getBaseValue("number")+n*7500),i=await A(Z).getUtxos({address:et(o),fetchTxHex:!0,targetValue:d}),p=Number(n.toFixed(0)),c=r?E(r):null,u=[];if(u.push({address:G(t),value:e.getBaseValue("number")}),c)u.push({script:c,value:0});let{inputs:a,outputs:l}=M({chain:Z,feeRate:p,inputs:i,outputs:u});if(!(a&&l))throw new L("toolbox_utxo_insufficient_balance",{assetValue:e,sender:o});let h=new gr({allowUnknownOutputs:!!c,version:1}),{inputs:m,tx:f}=ce({chain:Z,compiledMemo:c,inputs:a,outputs:l,sender:G(o),tx:h});return{inputs:m,tx:f,utxos:i}}function xo(e){let t=To.bitcoinCash,r=yr(e.publicKey,t);if(!r.hash)throw new L("toolbox_utxo_invalid_address",{error:"Could not derive BCH address hash"});return mr({hash:r.hash,prefix:fr.MAINNET,type:Tr.P2PKH}).replace(/^bitcoincash:/,"")}import{createBase58check as bo,hex as wo}from"@scure/base";import{HDKey as Ur}from"@scure/bip32";import{mnemonicToSeedSync as _r}from"@scure/bip39";import{Chain as V,derivationPathToString as Po,FeeOption as Uo,SwapKitError as Q}from"@swapkit/helpers";import{Address as _o,createZcashTransaction as vo,getZcashTransactionFormat as Ao,isTransparentZcashAddress as wr,OutScript as Oo,PCZT as So,utils as vr,WIF as Co,ZcashPSBT as Xo,ZcashSigHash as Ut}from"@swapkit/utxo-signer";import{match as Bo,P as _t}from"ts-pattern";var ko=bo(vr.sha256);function Ko(e){return ko.encode(e)}function Fo({phrase:e,derivationPath:t}){let r=_r(e),o=Ur.fromMasterSeed(r).derive(t);if(!o.privateKey||!o.publicKey)throw new Q("toolbox_utxo_invalid_params");let{privateKey:s,publicKey:d}=o,i=vr.hash160(d),p=new Uint8Array([28,184]),c=new Uint8Array(p.length+i.length);c.set(p,0),c.set(i,p.length);let u=Ko(c);return{getAddress:()=>Promise.resolve(u),signTransaction:(a)=>{if(a instanceof Xo){let l=a.toPCZT();return l.signAllInputs(s,d,Ut.ALL),l.finalizeAllInputs(),Promise.resolve(l.extract())}if(a instanceof So)return a.signAllInputs(s,d,Ut.ALL),a.finalizeAllInputs(),Promise.resolve(a.extract());return a.signAllInputs(s,d,Ut.ALL),Promise.resolve(a)}}}function Do({inputs:e,outputs:t,tx:r,sender:n,compiledMemo:o}){let s=U(V.Zcash);for(let d of e){let i=_o(s).decode(n),p=Oo.encode(i);r.addInput({index:d.index,script:p,sequence:4294967295,txid:wo.decode(d.hash),value:BigInt(d.value)})}for(let d of t){let i="address"in d&&d.address?d.address:n,p=d.script;if(p&&!o)continue;if(p&&o)r.addOutput({amount:0n,script:o});else r.addOutputAddress(i,BigInt(d.value),s)}return{inputs:e,tx:r}}async function Io(){try{let e=await A(V.Zcash).getBlockHeight();return Ao(e+1)}catch(e){throw new Q({errorKey:"toolbox_utxo_api_error",info:{chain:V.Zcash,reason:"Block height is required to choose the Zcash transaction format"}},e)}}async function Pr(e){let{assetValue:t,recipient:r,memo:n,feeRate:o,sender:s,fetchTxHex:d,sweep:i}=e,p=U(V.Zcash);if(!wr(s,p))throw new Q("toolbox_utxo_invalid_address",{address:s});if(!wr(r,p))throw new Q("toolbox_utxo_invalid_address",{address:r,error:"Zcash transaction creation currently supports transparent addresses only"});let c=n?E(n):null,u=await A(V.Zcash).getUtxos({address:s,fetchTxHex:d!==!1}),a=[{address:r,value:i?0:Number(t.getBaseValue("string"))},...c?[{script:c,value:0}]:[]],{inputs:l,outputs:h}=M({chain:V.Zcash,changeAddress:s,feeRate:o,inputs:u,outputs:a,sweep:i});if(!(l&&h))throw new Q("toolbox_utxo_insufficient_balance",{assetValue:t,sender:s});let m=vo({...await Io(),expiryHeight:0,lockTime:0}),{tx:f,inputs:y}=Do({compiledMemo:c,inputs:l,outputs:h,sender:s,tx:m});return{inputs:y,outputs:h,tx:f}}function Ar(e={}){let t="scriptType"in e?e.scriptType:void 0,r=Bo(e).with({signer:_t.not(_t.nullish)},({signer:c})=>c).with({phrase:_t.string},({phrase:c,derivationPath:u,index:a=0})=>{let{derivationPath:l}=Le({chain:V.Zcash,derivationPath:u,index:a,scriptType:t}),h=Po(l);return Fo({derivationPath:h,phrase:c})}).otherwise(()=>{return}),n=de({chain:V.Zcash,scriptType:t,signer:r});async function o(c){if(!r)throw new Q("toolbox_utxo_no_signer");return await r.signTransaction(c)}async function s(c){let u=await o(c);return n.broadcastTx(u.toHex())}async function d({recipient:c,assetValue:u,feeOptionKey:a=Uo.Fast,sweep:l,...h}){let m=await r?.getAddress();if(!(r&&m))throw new Q("toolbox_utxo_no_signer");let f=h.feeRate||(await n.getFeeRates())[a],{tx:y}=await Pr({...h,assetValue:u,feeRate:f,recipient:c,sender:m,sweep:l}),S=(await r.signTransaction(y)).toHex();return n.broadcastTx(S)}function i({phrase:c,derivationPath:u="m/44'/133'/0'/0/0"}){let a=_r(c),h=Ur.fromMasterSeed(a).derive(u);if(!h.privateKey||!h.publicKey)throw new Q("toolbox_utxo_invalid_params");return{privateKey:h.privateKey,publicKey:h.publicKey}}function p({phrase:c,derivationPath:u="m/44'/133'/0'/0/0"}){let a=i({derivationPath:u,phrase:c}),l=U(V.Zcash);return Co(l).encode(a.privateKey)}return{...n,createKeysForPath:i,createTransaction:Pr,getPrivateKeyFromMnemonic:p,signAndBroadcastTransaction:s,signTransaction:o,transfer:d,validateAddress:Pt}}import{hex as Ho}from"@scure/base";import{HDKey as Ro}from"@scure/bip32";import{derivationPathToString as Eo,NetworkDerivationPath as Mo,updateDerivationPath as No}from"@swapkit/helpers";function Zo({xpub:e,chain:t,count:r,startIndex:n=0,accountIndex:o,purpose:s,scriptType:d}){if(z("count",r),r<1)throw RangeError("count must be at least 1");z("startIndex",n),$e(t,d),dt({chain:t,purpose:s,scriptType:d});let i=U(t),p=Ro.fromExtendedKey(e,i.bip32),c=s===void 0?void 0:No(Mo[t],{purpose:s}),u=re({accountIndex:o,chain:t,derivationPath:c}),a=pe(u),l=[];for(let h of[!1,!0]){let m=p.deriveChild(Number(h));for(let f=0;f<r;f++){let y=n+f,b=m.deriveChild(y);if(!b.publicKey)continue;let S=Oe({accountIndex:o,chain:t,change:h,derivationPath:c,index:y});l.push({accountIndex:a,address:De({chain:t,network:i,publicKey:b.publicKey,scriptType:d}),change:h,index:y,pubkey:Ho.encode(b.publicKey),...s===void 0?{}:{path:Eo(S)}})}}return l}function Ii(e,t){switch(e){case Pe.BitcoinCash:return xr(t||{});case Pe.Zcash:return Ar(t);case Pe.Bitcoin:case Pe.Dogecoin:case Pe.Litecoin:case Pe.Dash:return de({chain:e,...t});default:throw new zo("toolbox_utxo_not_supported",{chain:e})}}export{Yt as InputSizes,_s as MIN_TX_FEE,Fn as OP_RETURN_OVERHEAD,lt as OutputSizes,Kn as SEGWIT_MARKER_FLAG_WEIGHT,ht as TX_OVERHEAD,ie as UTXOScriptType,It as UtxoNetwork,M as accumulative,ce as addInputsAndOutputs,lr as addressFromKeysGetter,z as assertDerivationIndex,ge as calculateTxSize,Zn as canSignBitcoinMessage,E as compileMemo,xr as createBCHToolbox,Yo as createCustomUtxoApi,Fr as createHDWalletHelpers,de as createUTXOToolbox,Ar as createZcashToolbox,Zo as deriveAddressesFromXpub,ss as detectAddressNetwork,Ce as getBchAddressType,Ke as getDustThreshold,ke as getInputScriptType,se as getInputSize,wt as getMissingSpendingMetadata,U as getNetworkForChain,je as getOutputSize,Dn as getOutputSizeForAddress,Ge as getScriptTypeForAddress,pe as getUTXOAccountIndexFromPath,re as getUTXOAccountPath,Oe as getUTXOAddressPath,pr as getUTXOAddressValidator,j as getUtxoAddressType,A as getUtxoApi,Go as getUtxoNetwork,Ii as getUtxoToolbox,Tt as getWitnessOverhead,co as getZcashAddressType,ft as isSegwitScriptType,os as isValidAddress,zt as nonSegwitChains,W as stripPrefix,et as stripToCashAddress,Me as toCashAddress,G as toLegacyAddress,Ne as tryDecodeAddress,Ie as validateBchAddress,sr as validateUtxoAddress,Pt as validateZcashAddress};
@@ -33,6 +33,10 @@ export declare function buildEIP712DomainType(domain: {
33
33
  name: "chainId" | "name" | "version" | "verifyingContract" | "salt";
34
34
  type: "string" | "address" | "uint256" | "bytes32";
35
35
  }[];
36
+ export declare function normalizeTypedDataForSigner<TTypedData extends {
37
+ domain: Parameters<typeof buildEIP712DomainType>[0];
38
+ types: Record<string, unknown>;
39
+ }>(typedData: TTypedData): TTypedData;
36
40
  export declare function parseEIP712FromEVMTx({ chain, abi, data, to, }: {
37
41
  chain: EVMChain;
38
42
  abi: readonly JsonFragment[];
@@ -174,7 +174,7 @@ export declare function BaseEVMToolbox<P extends Provider | BrowserProvider, S e
174
174
  chainId?: bigint;
175
175
  }) => Promise<import("ethers").Authorization>) | undefined;
176
176
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
177
- signTypedData: (({ domain, types, value }: SignTypedDataParams) => Promise<string>) | undefined;
177
+ signTypedData: ((params: SignTypedDataParams) => Promise<string>) | undefined;
178
178
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: EVMTransferParams) => Promise<string>;
179
179
  validateAddress: typeof validateEVMAddress;
180
180
  };
@@ -172,7 +172,7 @@ export declare function ETHToolbox(params: EVMToolboxParams): {
172
172
  chainId?: bigint;
173
173
  }) => Promise<import("ethers").Authorization>) | undefined;
174
174
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
175
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
175
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
176
176
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
177
177
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
178
178
  };
@@ -344,7 +344,7 @@ export declare const ADIToolbox: ({ provider, ...toolboxParams }: EVMToolboxPara
344
344
  chainId?: bigint;
345
345
  }) => Promise<import("ethers").Authorization>) | undefined;
346
346
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
347
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
347
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
348
348
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
349
349
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
350
350
  };
@@ -516,7 +516,7 @@ export declare const ARBToolbox: ({ provider, ...toolboxParams }: EVMToolboxPara
516
516
  chainId?: bigint;
517
517
  }) => Promise<import("ethers").Authorization>) | undefined;
518
518
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
519
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
519
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
520
520
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
521
521
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
522
522
  };
@@ -688,7 +688,7 @@ export declare const ARCToolbox: ({ provider, ...toolboxParams }: EVMToolboxPara
688
688
  chainId?: bigint;
689
689
  }) => Promise<import("ethers").Authorization>) | undefined;
690
690
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
691
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
691
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
692
692
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
693
693
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
694
694
  };
@@ -860,7 +860,7 @@ export declare const AURORAToolbox: ({ provider, ...toolboxParams }: EVMToolboxP
860
860
  chainId?: bigint;
861
861
  }) => Promise<import("ethers").Authorization>) | undefined;
862
862
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
863
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
863
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
864
864
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
865
865
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
866
866
  };
@@ -1032,7 +1032,7 @@ export declare const AVAXToolbox: ({ provider, ...toolboxParams }: EVMToolboxPar
1032
1032
  chainId?: bigint;
1033
1033
  }) => Promise<import("ethers").Authorization>) | undefined;
1034
1034
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
1035
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1035
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1036
1036
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
1037
1037
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
1038
1038
  };
@@ -1210,7 +1210,7 @@ export declare const BASEToolbox: ({ provider, ...toolboxSignerParams }: EVMTool
1210
1210
  chainId?: bigint;
1211
1211
  }) => Promise<import("ethers").Authorization>) | undefined;
1212
1212
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
1213
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1213
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1214
1214
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
1215
1215
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
1216
1216
  };
@@ -1382,7 +1382,7 @@ export declare const BERAToolbox: ({ provider, ...toolboxParams }: EVMToolboxPar
1382
1382
  chainId?: bigint;
1383
1383
  }) => Promise<import("ethers").Authorization>) | undefined;
1384
1384
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
1385
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1385
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1386
1386
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
1387
1387
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
1388
1388
  };
@@ -1554,7 +1554,7 @@ export declare const BSCToolbox: ({ provider, ...toolboxParams }: EVMToolboxPara
1554
1554
  chainId?: bigint;
1555
1555
  }) => Promise<import("ethers").Authorization>) | undefined;
1556
1556
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
1557
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1557
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1558
1558
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
1559
1559
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
1560
1560
  };
@@ -1726,7 +1726,7 @@ export declare const BotanixToolbox: ({ provider, ...toolboxParams }: EVMToolbox
1726
1726
  chainId?: bigint;
1727
1727
  }) => Promise<import("ethers").Authorization>) | undefined;
1728
1728
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
1729
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1729
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1730
1730
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
1731
1731
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
1732
1732
  };
@@ -1898,7 +1898,7 @@ export declare const COREToolbox: ({ provider, ...toolboxParams }: EVMToolboxPar
1898
1898
  chainId?: bigint;
1899
1899
  }) => Promise<import("ethers").Authorization>) | undefined;
1900
1900
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
1901
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1901
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
1902
1902
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
1903
1903
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
1904
1904
  };
@@ -2070,7 +2070,7 @@ export declare const CORNToolbox: ({ provider, ...toolboxParams }: EVMToolboxPar
2070
2070
  chainId?: bigint;
2071
2071
  }) => Promise<import("ethers").Authorization>) | undefined;
2072
2072
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
2073
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2073
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2074
2074
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
2075
2075
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
2076
2076
  };
@@ -2242,7 +2242,7 @@ export declare const CROToolbox: ({ provider, ...toolboxParams }: EVMToolboxPara
2242
2242
  chainId?: bigint;
2243
2243
  }) => Promise<import("ethers").Authorization>) | undefined;
2244
2244
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
2245
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2245
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2246
2246
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
2247
2247
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
2248
2248
  };
@@ -2414,7 +2414,7 @@ export declare const GNOToolbox: ({ provider, ...toolboxParams }: EVMToolboxPara
2414
2414
  chainId?: bigint;
2415
2415
  }) => Promise<import("ethers").Authorization>) | undefined;
2416
2416
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
2417
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2417
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2418
2418
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
2419
2419
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
2420
2420
  };
@@ -2586,7 +2586,7 @@ export declare const HOODToolbox: ({ provider, ...toolboxParams }: EVMToolboxPar
2586
2586
  chainId?: bigint;
2587
2587
  }) => Promise<import("ethers").Authorization>) | undefined;
2588
2588
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
2589
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2589
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2590
2590
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
2591
2591
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
2592
2592
  };
@@ -2758,7 +2758,7 @@ export declare const HYPEREVMToolbox: ({ provider, ...toolboxParams }: EVMToolbo
2758
2758
  chainId?: bigint;
2759
2759
  }) => Promise<import("ethers").Authorization>) | undefined;
2760
2760
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
2761
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2761
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2762
2762
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
2763
2763
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
2764
2764
  };
@@ -2930,7 +2930,7 @@ export declare const LINEAToolbox: ({ provider, ...toolboxParams }: EVMToolboxPa
2930
2930
  chainId?: bigint;
2931
2931
  }) => Promise<import("ethers").Authorization>) | undefined;
2932
2932
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
2933
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2933
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
2934
2934
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
2935
2935
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
2936
2936
  };
@@ -3102,7 +3102,7 @@ export declare const MATICToolbox: ({ provider, ...toolboxParams }: EVMToolboxPa
3102
3102
  chainId?: bigint;
3103
3103
  }) => Promise<import("ethers").Authorization>) | undefined;
3104
3104
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
3105
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3105
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3106
3106
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
3107
3107
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
3108
3108
  };
@@ -3274,7 +3274,7 @@ export declare const MEGAETHToolbox: ({ provider, ...toolboxParams }: EVMToolbox
3274
3274
  chainId?: bigint;
3275
3275
  }) => Promise<import("ethers").Authorization>) | undefined;
3276
3276
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
3277
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3277
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3278
3278
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
3279
3279
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
3280
3280
  };
@@ -3446,7 +3446,7 @@ export declare const MONADToolbox: ({ provider, ...toolboxParams }: EVMToolboxPa
3446
3446
  chainId?: bigint;
3447
3447
  }) => Promise<import("ethers").Authorization>) | undefined;
3448
3448
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
3449
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3449
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3450
3450
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
3451
3451
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
3452
3452
  };
@@ -3618,7 +3618,7 @@ export declare const PLASMAToolbox: ({ provider, ...toolboxParams }: EVMToolboxP
3618
3618
  chainId?: bigint;
3619
3619
  }) => Promise<import("ethers").Authorization>) | undefined;
3620
3620
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
3621
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3621
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3622
3622
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
3623
3623
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
3624
3624
  };
@@ -3790,7 +3790,7 @@ export declare const SONICToolbox: ({ provider, ...toolboxParams }: EVMToolboxPa
3790
3790
  chainId?: bigint;
3791
3791
  }) => Promise<import("ethers").Authorization>) | undefined;
3792
3792
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
3793
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3793
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3794
3794
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
3795
3795
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
3796
3796
  };
@@ -3968,7 +3968,7 @@ export declare const UNIToolbox: ({ provider, ...toolboxSignerParams }: EVMToolb
3968
3968
  chainId?: bigint;
3969
3969
  }) => Promise<import("ethers").Authorization>) | undefined;
3970
3970
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
3971
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3971
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
3972
3972
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
3973
3973
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
3974
3974
  };
@@ -4140,7 +4140,7 @@ export declare const XLayerToolbox: ({ provider, ...toolboxParams }: EVMToolboxP
4140
4140
  chainId?: bigint;
4141
4141
  }) => Promise<import("ethers").Authorization>) | undefined;
4142
4142
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
4143
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
4143
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
4144
4144
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
4145
4145
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
4146
4146
  };
@@ -184,7 +184,7 @@ export declare function createOPStackToolbox(chain: Chain.Optimism | Chain.Base
184
184
  chainId?: bigint;
185
185
  }) => Promise<Authorization>) | undefined;
186
186
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
187
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
187
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
188
188
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
189
189
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
190
190
  };
@@ -362,7 +362,7 @@ export declare const OPToolbox: ({ provider, ...toolboxSignerParams }: EVMToolbo
362
362
  chainId?: bigint;
363
363
  }) => Promise<Authorization>) | undefined;
364
364
  signMessage: ((message: string | Uint8Array) => Promise<string>) | undefined;
365
- signTypedData: (({ domain, types, value }: import("..").SignTypedDataParams) => Promise<string>) | undefined;
365
+ signTypedData: ((params: import("..").SignTypedDataParams) => Promise<string>) | undefined;
366
366
  transfer: ({ assetValue, memo, recipient, feeOptionKey, sender, sweep, ...tx }: import("..").EVMTransferParams) => Promise<string>;
367
367
  validateAddress: typeof import("./baseEVMToolbox").validateEVMAddress;
368
368
  };
@@ -2,7 +2,7 @@ import type { ChainSigner, DerivationPathArray, FeeOption, GenericCreateTransact
2
2
  import { Chain } from "@swapkit/helpers";
3
3
  import type { AuthorizationLike, BigNumberish, BrowserProvider, JsonFragment, JsonRpcSigner, Provider, Signer, TransactionRequest, TypedDataField } from "ethers";
4
4
  import type { getProvider } from "./index";
5
- import type { ADIToolbox, ARBToolbox, ARCToolbox, AURORAToolbox, AVAXToolbox, BASEToolbox, BERAToolbox, BSCToolbox, COREToolbox, CORNToolbox, CROToolbox, ETHToolbox, GNOToolbox, HOODToolbox, HYPEREVMToolbox, LINEAToolbox, MATICToolbox, MEGAETHToolbox, MONADToolbox, OPToolbox, PLASMAToolbox, SONICToolbox, UNIToolbox, XLayerToolbox } from "./toolbox";
5
+ import type { ADIToolbox, ARBToolbox, ARCToolbox, AURORAToolbox, AVAXToolbox, BASEToolbox, BERAToolbox, BotanixToolbox, BSCToolbox, COREToolbox, CORNToolbox, CROToolbox, ETHToolbox, GNOToolbox, HOODToolbox, HYPEREVMToolbox, LINEAToolbox, MATICToolbox, MEGAETHToolbox, MONADToolbox, OPToolbox, PLASMAToolbox, SONICToolbox, UNIToolbox, XLayerToolbox } from "./toolbox";
6
6
  export declare enum EthNetwork {
7
7
  Test = "goerli",
8
8
  Main = "homestead"
@@ -107,7 +107,7 @@ export type EVMToolboxes = {
107
107
  [Chain.Base]: ReturnType<typeof BASEToolbox>;
108
108
  [Chain.Berachain]: ReturnType<typeof BERAToolbox>;
109
109
  [Chain.BinanceSmartChain]: ReturnType<typeof BSCToolbox>;
110
- [Chain.Botanix]: ReturnType<typeof SONICToolbox>;
110
+ [Chain.Botanix]: ReturnType<typeof BotanixToolbox>;
111
111
  [Chain.Core]: ReturnType<typeof COREToolbox>;
112
112
  [Chain.Corn]: ReturnType<typeof CORNToolbox>;
113
113
  [Chain.Cronos]: ReturnType<typeof CROToolbox>;
@@ -12,5 +12,4 @@ interface AssertSendAssetPayloadParams {
12
12
  submitTo: string;
13
13
  typedData: HyperCoreTypedData;
14
14
  }
15
- export declare function sanitizeTypedDataForSigner<TTypedData extends HyperCoreTypedData>(typedData: TTypedData): TTypedData;
16
15
  export declare function assertSendAssetPayload({ action, allowedEndpoints, expectedAmount, expectedDestination, expectedFromSubAccount, expectedSourceDex, expectedToken, submitTo, typedData, }: AssertSendAssetPayloadParams): void;
@@ -0,0 +1,37 @@
1
+ export declare const SUI_COIN_TYPE = "0x2::sui::SUI";
2
+ export declare const LONG_SUI_COIN_TYPE = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
3
+ type MockCoin = {
4
+ balance: string;
5
+ digest: string;
6
+ objectId: string;
7
+ version: string;
8
+ };
9
+ type MockStatus = {
10
+ success: true;
11
+ error: null;
12
+ } | {
13
+ success: false;
14
+ error: {
15
+ message: string;
16
+ };
17
+ };
18
+ export declare const suiRpc: {
19
+ balances: {
20
+ balance: string;
21
+ coinType: string;
22
+ }[];
23
+ calls: {
24
+ method: string;
25
+ params: unknown;
26
+ }[];
27
+ clientUrls: string[];
28
+ coinPages: Record<string, MockCoin[][]>;
29
+ count(method: string): number;
30
+ danglingNextPage: boolean;
31
+ error: Error | undefined;
32
+ reset(): void;
33
+ simulateStatus: MockStatus;
34
+ };
35
+ export declare function mockSuiGrpc(): void;
36
+ export declare function restoreSuiGrpc(): void;
37
+ export {};
@@ -156,6 +156,7 @@ export declare function toolboxFor(scriptType: FlowScriptType): {
156
156
  } | undefined;
157
157
  scriptType: UTXOScriptType;
158
158
  signAndBroadcastTransaction: (tx: InstanceType<typeof Transaction>) => Promise<string>;
159
+ signMessage: ((message: string) => Promise<string>) | undefined;
159
160
  signTransaction: (tx: InstanceType<typeof Transaction>) => Transaction | Promise<Transaction>;
160
161
  signTransactionWithMultipleKeys: ({ tx, inputDerivations, }: {
161
162
  tx: InstanceType<typeof Transaction>;
@@ -1,4 +1,5 @@
1
1
  export * from "./api";
2
2
  export * from "./bchaddrjs";
3
3
  export * from "./coinselect";
4
+ export { canSignBitcoinMessage } from "./messageSigning";
4
5
  export * from "./txSize";
@@ -0,0 +1,7 @@
1
+ import { UTXOScriptType } from "@swapkit/helpers";
2
+ export declare function canSignBitcoinMessage(scriptType: UTXOScriptType): boolean;
3
+ export declare function signBitcoinMessage({ message, privateKey, scriptType, }: {
4
+ message: string;
5
+ privateKey: Uint8Array;
6
+ scriptType: UTXOScriptType;
7
+ }): string;
@@ -111,6 +111,7 @@ export declare function createBCHToolbox<T extends typeof Chain.BitcoinCash>(too
111
111
  index: number;
112
112
  } | undefined;
113
113
  scriptType: import("@swapkit/helpers").UTXOScriptType;
114
+ signMessage: ((message: string) => Promise<string>) | undefined;
114
115
  signTransactionWithMultipleKeys: ({ tx, inputDerivations, }: {
115
116
  tx: InstanceType<typeof Transaction>;
116
117
  inputDerivations: import("..").InputDerivation[];
@@ -207,6 +207,7 @@ export declare function createUTXOToolbox<T extends UTXOChain>(toolboxParams: (U
207
207
  } | undefined;
208
208
  scriptType: UTXOScriptType;
209
209
  signAndBroadcastTransaction: (tx: InstanceType<typeof Transaction>) => Promise<string>;
210
+ signMessage: ((message: string) => Promise<string>) | undefined;
210
211
  signTransaction: (tx: InstanceType<typeof Transaction>) => Transaction | Promise<Transaction>;
211
212
  signTransactionWithMultipleKeys: ({ tx, inputDerivations, }: {
212
213
  tx: InstanceType<typeof Transaction>;
@@ -116,6 +116,7 @@ export declare function createZcashToolbox(toolboxParams?: {
116
116
  index: number;
117
117
  } | undefined;
118
118
  scriptType: import("@swapkit/helpers").UTXOScriptType;
119
+ signMessage: ((message: string) => Promise<string>) | undefined;
119
120
  signTransactionWithMultipleKeys: ({ tx, inputDerivations, }: {
120
121
  tx: InstanceType<typeof import("@swapkit/utxo-signer").Transaction>;
121
122
  inputDerivations: import("..").InputDerivation[];