mainnet-js 2.7.34 → 3.0.0-next.1

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 (195) hide show
  1. package/dist/index.html +1 -1
  2. package/dist/{mainnet-2.7.34.js → mainnet-3.0.0-next.1.js} +728 -708
  3. package/dist/module/cache/MemoryCache.d.ts +0 -1
  4. package/dist/module/cache/MemoryCache.d.ts.map +1 -1
  5. package/dist/module/cache/MemoryCache.js +5 -7
  6. package/dist/module/cache/MemoryCache.js.map +1 -1
  7. package/dist/module/cache/index.d.ts +1 -0
  8. package/dist/module/cache/index.d.ts.map +1 -1
  9. package/dist/module/cache/index.js +1 -0
  10. package/dist/module/cache/index.js.map +1 -1
  11. package/dist/module/cache/walletCache.d.ts +45 -0
  12. package/dist/module/cache/walletCache.d.ts.map +1 -0
  13. package/dist/module/cache/walletCache.js +140 -0
  14. package/dist/module/cache/walletCache.js.map +1 -0
  15. package/dist/module/chain.d.ts +1 -1
  16. package/dist/module/chain.js +1 -1
  17. package/dist/module/chain.js.map +1 -1
  18. package/dist/module/constant.d.ts +1 -1
  19. package/dist/module/constant.d.ts.map +1 -1
  20. package/dist/module/constant.js +1 -1
  21. package/dist/module/constant.js.map +1 -1
  22. package/dist/module/enum.d.ts +1 -7
  23. package/dist/module/enum.d.ts.map +1 -1
  24. package/dist/module/enum.js +0 -6
  25. package/dist/module/enum.js.map +1 -1
  26. package/dist/module/history/{electrumTransformer.d.ts → getHistory.d.ts} +3 -3
  27. package/dist/module/history/getHistory.d.ts.map +1 -0
  28. package/dist/module/history/{electrumTransformer.js → getHistory.js} +17 -14
  29. package/dist/module/history/getHistory.js.map +1 -0
  30. package/dist/module/index.d.ts +3 -1
  31. package/dist/module/index.d.ts.map +1 -1
  32. package/dist/module/index.js +3 -1
  33. package/dist/module/index.js.map +1 -1
  34. package/dist/module/interface.d.ts +7 -2
  35. package/dist/module/interface.d.ts.map +1 -1
  36. package/dist/module/interface.js.map +1 -1
  37. package/dist/module/message/interface.d.ts +2 -2
  38. package/dist/module/message/interface.d.ts.map +1 -1
  39. package/dist/module/message/interface.js +0 -3
  40. package/dist/module/message/interface.js.map +1 -1
  41. package/dist/module/message/signed.d.ts +5 -5
  42. package/dist/module/message/signed.d.ts.map +1 -1
  43. package/dist/module/message/signed.js +8 -8
  44. package/dist/module/message/signed.js.map +1 -1
  45. package/dist/module/network/ElectrumNetworkProvider.d.ts +2 -2
  46. package/dist/module/network/ElectrumNetworkProvider.d.ts.map +1 -1
  47. package/dist/module/network/ElectrumNetworkProvider.js +3 -2
  48. package/dist/module/network/ElectrumNetworkProvider.js.map +1 -1
  49. package/dist/module/network/NetworkProvider.d.ts +2 -2
  50. package/dist/module/network/NetworkProvider.d.ts.map +1 -1
  51. package/dist/module/network/constant.js +4 -4
  52. package/dist/module/network/constant.js.map +1 -1
  53. package/dist/module/network/getRelayFeeCache.js +2 -2
  54. package/dist/module/network/getRelayFeeCache.js.map +1 -1
  55. package/dist/module/rate/ExchangeRate.d.ts +2 -1
  56. package/dist/module/rate/ExchangeRate.d.ts.map +1 -1
  57. package/dist/module/rate/ExchangeRate.js +4 -1
  58. package/dist/module/rate/ExchangeRate.js.map +1 -1
  59. package/dist/module/transaction/Wif.d.ts +25 -23
  60. package/dist/module/transaction/Wif.d.ts.map +1 -1
  61. package/dist/module/transaction/Wif.js +26 -25
  62. package/dist/module/transaction/Wif.js.map +1 -1
  63. package/dist/module/transaction/allocateFee.d.ts +3 -3
  64. package/dist/module/transaction/allocateFee.d.ts.map +1 -1
  65. package/dist/module/transaction/allocateFee.js +5 -6
  66. package/dist/module/transaction/allocateFee.js.map +1 -1
  67. package/dist/module/util/amountInSatoshi.d.ts +1 -1
  68. package/dist/module/util/amountInSatoshi.d.ts.map +1 -1
  69. package/dist/module/util/amountInSatoshi.js +3 -9
  70. package/dist/module/util/amountInSatoshi.js.map +1 -1
  71. package/dist/module/util/asSendRequestObject.d.ts.map +1 -1
  72. package/dist/module/util/asSendRequestObject.js +10 -7
  73. package/dist/module/util/asSendRequestObject.js.map +1 -1
  74. package/dist/module/util/checkUtxos.d.ts +2 -2
  75. package/dist/module/util/checkUtxos.d.ts.map +1 -1
  76. package/dist/module/util/checkUtxos.js +11 -12
  77. package/dist/module/util/checkUtxos.js.map +1 -1
  78. package/dist/module/util/convert.d.ts +3 -0
  79. package/dist/module/util/convert.d.ts.map +1 -1
  80. package/dist/module/util/convert.js +12 -0
  81. package/dist/module/util/convert.js.map +1 -1
  82. package/dist/module/util/deriveCashaddr.d.ts.map +1 -1
  83. package/dist/module/util/deriveCashaddr.js +6 -0
  84. package/dist/module/util/deriveCashaddr.js.map +1 -1
  85. package/dist/module/util/deriveNetwork.js +1 -1
  86. package/dist/module/util/deriveNetwork.js.map +1 -1
  87. package/dist/module/util/hd.d.ts +3 -0
  88. package/dist/module/util/hd.d.ts.map +1 -0
  89. package/dist/module/util/hd.js +11 -0
  90. package/dist/module/util/hd.js.map +1 -0
  91. package/dist/module/util/index.d.ts +3 -3
  92. package/dist/module/util/index.d.ts.map +1 -1
  93. package/dist/module/util/index.js +3 -3
  94. package/dist/module/util/index.js.map +1 -1
  95. package/dist/module/util/satoshiToAmount.d.ts +1 -1
  96. package/dist/module/util/satoshiToAmount.d.ts.map +1 -1
  97. package/dist/module/util/satoshiToAmount.js +3 -9
  98. package/dist/module/util/satoshiToAmount.js.map +1 -1
  99. package/dist/module/util/sumSendRequestAmounts.d.ts.map +1 -1
  100. package/dist/module/util/sumSendRequestAmounts.js +3 -4
  101. package/dist/module/util/sumSendRequestAmounts.js.map +1 -1
  102. package/dist/module/util/sumUtxoValue.d.ts +3 -3
  103. package/dist/module/util/sumUtxoValue.d.ts.map +1 -1
  104. package/dist/module/util/sumUtxoValue.js +2 -2
  105. package/dist/module/util/sumUtxoValue.js.map +1 -1
  106. package/dist/module/wallet/Base.d.ts +45 -103
  107. package/dist/module/wallet/Base.d.ts.map +1 -1
  108. package/dist/module/wallet/Base.js +99 -298
  109. package/dist/module/wallet/Base.js.map +1 -1
  110. package/dist/module/wallet/HDWallet.d.ts +164 -0
  111. package/dist/module/wallet/HDWallet.d.ts.map +1 -0
  112. package/dist/module/wallet/HDWallet.js +486 -0
  113. package/dist/module/wallet/HDWallet.js.map +1 -0
  114. package/dist/module/wallet/Util.js +1 -1
  115. package/dist/module/wallet/Util.js.map +1 -1
  116. package/dist/module/wallet/Watch.d.ts +151 -0
  117. package/dist/module/wallet/Watch.d.ts.map +1 -0
  118. package/dist/module/wallet/Watch.js +307 -0
  119. package/dist/module/wallet/Watch.js.map +1 -0
  120. package/dist/module/wallet/Wif.d.ts +23 -29
  121. package/dist/module/wallet/Wif.d.ts.map +1 -1
  122. package/dist/module/wallet/Wif.js +204 -267
  123. package/dist/module/wallet/Wif.js.map +1 -1
  124. package/dist/module/wallet/createWallet.d.ts +7 -1
  125. package/dist/module/wallet/createWallet.d.ts.map +1 -1
  126. package/dist/module/wallet/createWallet.js +26 -17
  127. package/dist/module/wallet/createWallet.js.map +1 -1
  128. package/dist/module/wallet/interface.d.ts +5 -6
  129. package/dist/module/wallet/interface.d.ts.map +1 -1
  130. package/dist/module/wallet/model.d.ts +15 -19
  131. package/dist/module/wallet/model.d.ts.map +1 -1
  132. package/dist/module/wallet/model.js +5 -25
  133. package/dist/module/wallet/model.js.map +1 -1
  134. package/dist/tsconfig.tsbuildinfo +1 -1
  135. package/package.json +1 -1
  136. package/src/cache/MemoryCache.ts +5 -5
  137. package/src/cache/index.ts +1 -0
  138. package/src/cache/walletCache.ts +239 -0
  139. package/src/chain.ts +1 -1
  140. package/src/constant.ts +1 -1
  141. package/src/enum.ts +0 -6
  142. package/src/history/{electrumTransformer.test.ts → getHistory.test.ts} +26 -53
  143. package/src/history/{electrumTransformer.ts → getHistory.ts} +31 -15
  144. package/src/index.ts +3 -1
  145. package/src/interface.ts +8 -2
  146. package/src/message/interface.ts +2 -28
  147. package/src/message/signed.test.ts +36 -48
  148. package/src/message/signed.ts +9 -12
  149. package/src/network/Connection.test.ts +3 -3
  150. package/src/network/ElectrumNetworkProvider.ts +5 -5
  151. package/src/network/NetworkProvider.ts +2 -2
  152. package/src/network/Rpc.test.ts +3 -4
  153. package/src/network/constant.ts +4 -4
  154. package/src/network/getRelayFeeCache.ts +2 -2
  155. package/src/rate/ExchangeRate.test.ts +2 -44
  156. package/src/rate/ExchangeRate.ts +5 -2
  157. package/src/transaction/Wif.ts +59 -52
  158. package/src/transaction/allocateFee.test.ts +110 -131
  159. package/src/transaction/allocateFee.ts +14 -15
  160. package/src/util/amountInSatoshi.test.ts +1 -9
  161. package/src/util/amountInSatoshi.ts +6 -10
  162. package/src/util/asSendRequestObject.ts +12 -7
  163. package/src/util/checkUtxos.ts +21 -26
  164. package/src/util/convert.ts +18 -0
  165. package/src/util/deriveCashaddr.ts +8 -0
  166. package/src/util/deriveNetwork.ts +1 -1
  167. package/src/util/derivePublicKeyHash.test.ts +0 -13
  168. package/src/util/hd.ts +16 -0
  169. package/src/util/index.ts +3 -7
  170. package/src/util/satoshiToAmount.test.ts +1 -1
  171. package/src/util/satoshiToAmount.ts +4 -10
  172. package/src/util/sumSendRequestAmounts.ts +3 -4
  173. package/src/util/sumUtxoValue.ts +7 -7
  174. package/src/wallet/Base.ts +147 -420
  175. package/src/wallet/Cashtokens.test.headless.js +11 -11
  176. package/src/wallet/Cashtokens.test.ts +36 -37
  177. package/src/wallet/HDWallet.test.ts +515 -0
  178. package/src/wallet/HDWallet.ts +764 -0
  179. package/src/wallet/Util.ts +1 -1
  180. package/src/wallet/Watch.ts +447 -0
  181. package/src/wallet/Wif.bip39.test.ts +1 -1
  182. package/src/wallet/Wif.test.ts +108 -133
  183. package/src/wallet/Wif.ts +258 -283
  184. package/src/wallet/createWallet.ts +28 -18
  185. package/src/wallet/interface.ts +5 -6
  186. package/src/wallet/model.test.ts +4 -7
  187. package/src/wallet/model.ts +19 -51
  188. package/dist/module/history/electrumTransformer.d.ts.map +0 -1
  189. package/dist/module/history/electrumTransformer.js.map +0 -1
  190. package/dist/module/util/balanceObjectFromSatoshi.d.ts +0 -8
  191. package/dist/module/util/balanceObjectFromSatoshi.d.ts.map +0 -1
  192. package/dist/module/util/balanceObjectFromSatoshi.js +0 -35
  193. package/dist/module/util/balanceObjectFromSatoshi.js.map +0 -1
  194. package/src/util/balanceObjectFromSatoshi.test.ts +0 -58
  195. package/src/util/balanceObjectFromSatoshi.ts +0 -52
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  walletTemplateP2pkhNonHd,
3
- walletTemplateToCompilerBCH,
4
3
  cashAddressToLockingBytecode,
5
4
  Compiler,
6
5
  encodeTransaction,
@@ -8,14 +7,15 @@ import {
8
7
  importWalletTemplate,
9
8
  AnyCompilerConfiguration,
10
9
  AuthenticationProgramStateCommon,
11
- CompilationContextBCH,
12
10
  Output,
13
11
  hexToBin,
14
12
  verifyTransactionTokens,
15
13
  decodeTransaction,
16
14
  TransactionTemplateFixed,
15
+ CompilationContextBch,
16
+ walletTemplateToCompilerBch,
17
17
  } from "@bitauth/libauth";
18
- import { NFTCapability, TokenI, UtxoI } from "../interface.js";
18
+ import { NFTCapability, TokenI, Utxo } from "../interface.js";
19
19
  import { allocateFee } from "./allocateFee.js";
20
20
 
21
21
  import { DUST_UTXO_THRESHOLD } from "../constant.js";
@@ -26,30 +26,34 @@ import {
26
26
  SourceOutput,
27
27
  TokenSendRequest,
28
28
  } from "../wallet/model.js";
29
- import { amountInSatoshi } from "../util/amountInSatoshi.js";
30
29
  import { sumSendRequestAmounts } from "../util/sumSendRequestAmounts.js";
31
30
  import { sumUtxoValue } from "../util/sumUtxoValue.js";
32
31
  import { FeePaidByEnum } from "../wallet/enum.js";
32
+ import { WalletCache } from "../cache/walletCache.js";
33
+
34
+ export const placeholderPrivateKey =
35
+ "0000000000000000000000000000000000000000000000000000000000000001";
36
+ export const placeholderPrivateKeyBin = hexToBin(placeholderPrivateKey);
33
37
 
34
38
  // Build a transaction for a p2pkh transaction for a non HD wallet
35
39
  export async function buildP2pkhNonHdTransaction({
36
40
  inputs,
37
41
  outputs,
38
42
  signingKey,
39
- sourceAddress,
40
- fee = 0,
43
+ fee = 0n,
41
44
  discardChange = false,
42
45
  feePaidBy = FeePaidByEnum.change,
43
46
  changeAddress = "",
47
+ walletCache,
44
48
  }: {
45
- inputs: UtxoI[];
49
+ inputs: Utxo[];
46
50
  outputs: Array<SendRequest | TokenSendRequest | OpReturnData>;
47
- signingKey: Uint8Array;
48
- sourceAddress: string;
49
- fee?: number;
51
+ signingKey?: Uint8Array;
52
+ fee?: bigint;
50
53
  discardChange?: boolean;
51
54
  feePaidBy?: FeePaidByEnum;
52
55
  changeAddress?: string;
56
+ walletCache?: WalletCache;
53
57
  }) {
54
58
  if (!signingKey) {
55
59
  throw new Error("Missing signing key when building transaction");
@@ -60,8 +64,8 @@ export async function buildP2pkhNonHdTransaction({
60
64
  throw new Error("Transaction template error");
61
65
  }
62
66
 
63
- const compiler = await walletTemplateToCompilerBCH(template);
64
- const inputAmount = await sumUtxoValue(inputs);
67
+ const compiler = walletTemplateToCompilerBch(template);
68
+ const inputAmount = sumUtxoValue(inputs);
65
69
 
66
70
  const sendAmount = await sumSendRequestAmounts(outputs);
67
71
 
@@ -72,7 +76,7 @@ export async function buildP2pkhNonHdTransaction({
72
76
  const lockedOutputs = await prepareOutputs(outputs);
73
77
 
74
78
  if (!changeAddress) {
75
- changeAddress = sourceAddress;
79
+ changeAddress = inputs[0].address;
76
80
  }
77
81
 
78
82
  if (discardChange !== true) {
@@ -92,7 +96,7 @@ export async function buildP2pkhNonHdTransaction({
92
96
  inputs,
93
97
  compiler,
94
98
  signingKey,
95
- sourceAddress,
99
+ walletCache,
96
100
  });
97
101
  const result = generateTransaction({
98
102
  inputs: preparedInputs,
@@ -121,16 +125,16 @@ export function prepareInputs({
121
125
  inputs,
122
126
  compiler,
123
127
  signingKey,
124
- sourceAddress,
128
+ walletCache,
125
129
  }: {
126
- inputs: UtxoI[];
130
+ inputs: Utxo[];
127
131
  compiler: Compiler<
128
- CompilationContextBCH,
129
- AnyCompilerConfiguration<CompilationContextBCH>,
132
+ CompilationContextBch,
133
+ AnyCompilerConfiguration<CompilationContextBch>,
130
134
  AuthenticationProgramStateCommon
131
135
  >;
132
136
  signingKey: Uint8Array;
133
- sourceAddress: string;
137
+ walletCache?: WalletCache;
134
138
  }) {
135
139
  const preparedInputs: any[] = [];
136
140
  const sourceOutputs: any[] = [];
@@ -160,7 +164,9 @@ export function prepareInputs({
160
164
  }
161
165
  : undefined,
162
166
  };
163
- const key = signingKey?.length ? signingKey : Uint8Array.from(Array(32));
167
+ const key =
168
+ walletCache?.get(i.address)?.privateKey ??
169
+ (signingKey?.length ? signingKey : Uint8Array.from(Array(32)));
164
170
  const newInput = {
165
171
  outpointIndex: utxoIndex,
166
172
  outpointTransactionHash: utxoOutpointTransactionHash,
@@ -178,7 +184,7 @@ export function prepareInputs({
178
184
 
179
185
  preparedInputs.push(newInput);
180
186
 
181
- const lockingBytecode = cashAddressToLockingBytecode(sourceAddress);
187
+ const lockingBytecode = cashAddressToLockingBytecode(i.address);
182
188
  if (typeof lockingBytecode === "string") {
183
189
  throw lockingBytecode;
184
190
  }
@@ -224,7 +230,7 @@ export async function prepareOutputs(
224
230
  if (typeof outputLockingBytecode === "string")
225
231
  throw new Error(outputLockingBytecode);
226
232
 
227
- const sendAmount = await amountInSatoshi(output.value, output.unit);
233
+ const sendAmount = Number(output.value);
228
234
  if (sendAmount % 1 !== 0) {
229
235
  throw Error(
230
236
  `Cannot send ${sendAmount} satoshis, (fractional sats do not exist, yet), please use an integer number.`
@@ -292,22 +298,22 @@ export function prepareTokenOutputs(request: TokenSendRequest): Output {
292
298
  * @returns A promise to a list of unspent outputs
293
299
  */
294
300
  export async function getSuitableUtxos(
295
- inputs: UtxoI[],
301
+ inputs: Utxo[],
296
302
  amountRequired: bigint | undefined,
297
303
  bestHeight: number,
298
304
  feePaidBy: FeePaidByEnum,
299
305
  requests: SendRequestType[],
300
- ensureUtxos: UtxoI[] = [],
306
+ ensureUtxos: Utxo[] = [],
301
307
  tokenOperation: "send" | "genesis" | "mint" | "burn" = "send"
302
- ): Promise<UtxoI[]> {
303
- const suitableUtxos: UtxoI[] = [...ensureUtxos];
308
+ ): Promise<Utxo[]> {
309
+ const suitableUtxos: Utxo[] = [...ensureUtxos];
304
310
  let amountAvailable = BigInt(0);
305
311
  const tokenRequests = requests.filter(
306
312
  (val) => val instanceof TokenSendRequest
307
313
  ) as TokenSendRequest[];
308
314
 
309
315
  const availableInputs = inputs.slice();
310
- const selectedInputs: UtxoI[] = [];
316
+ const selectedInputs: Utxo[] = [];
311
317
 
312
318
  // find matching utxos for token transfers
313
319
  if (tokenOperation === "send") {
@@ -438,14 +444,13 @@ export async function getFeeAmountSimple({
438
444
  relayFeePerByteInSatoshi,
439
445
  discardChange,
440
446
  }: {
441
- utxos: UtxoI[];
447
+ utxos: Utxo[];
442
448
  sendRequests: Array<SendRequest | TokenSendRequest | OpReturnData>;
443
- privateKey: Uint8Array;
444
449
  sourceAddress: string;
445
450
  relayFeePerByteInSatoshi: number;
446
451
  feePaidBy: FeePaidByEnum;
447
452
  discardChange?: boolean;
448
- }) {
453
+ }): Promise<bigint> {
449
454
  const inputSizeP2pkh = 148;
450
455
  const outputSizeP2pkh = 34;
451
456
 
@@ -462,10 +467,8 @@ export async function getFeeAmountSimple({
462
467
  0
463
468
  );
464
469
 
465
- const outputSize = (sendRequest) => {
466
- if (sendRequest.hasOwnProperty("unit")) {
467
- return outputSizeP2pkh;
468
- } else if (sendRequest.hasOwnProperty("tokenId")) {
470
+ const outputSize = (sendRequest: SendRequestType) => {
471
+ if (sendRequest.hasOwnProperty("tokenId")) {
469
472
  const tokenRequest = sendRequest as TokenSendRequest;
470
473
  return (
471
474
  outputSizeP2pkh +
@@ -476,17 +479,19 @@ export async function getFeeAmountSimple({
476
479
  );
477
480
  } else if (sendRequest.hasOwnProperty("buffer")) {
478
481
  return 9 + (sendRequest as OpReturnData).buffer.length;
482
+ } else {
483
+ return outputSizeP2pkh;
479
484
  }
480
-
481
- return 0;
482
485
  };
483
486
 
484
487
  const outputTotalSize =
485
488
  sendRequests.reduce((prev, curr) => prev + outputSize(curr), 0) +
486
489
  (discardChange ? 0 : outputSizeP2pkh);
487
490
 
488
- return Math.ceil(
489
- (inputTotalSize + outputTotalSize + 16) * relayFeePerByteInSatoshi
491
+ return BigInt(
492
+ Math.ceil(
493
+ (inputTotalSize + outputTotalSize + 16) * relayFeePerByteInSatoshi
494
+ )
490
495
  );
491
496
  }
492
497
 
@@ -494,19 +499,19 @@ export async function getFeeAmountSimple({
494
499
  export async function getFeeAmount({
495
500
  utxos,
496
501
  sendRequests,
497
- privateKey,
498
502
  sourceAddress,
499
503
  relayFeePerByteInSatoshi,
500
504
  feePaidBy,
501
505
  discardChange,
506
+ walletCache,
502
507
  }: {
503
- utxos: UtxoI[];
508
+ utxos: Utxo[];
504
509
  sendRequests: Array<SendRequest | TokenSendRequest | OpReturnData>;
505
- privateKey: Uint8Array;
506
510
  sourceAddress: string;
507
511
  relayFeePerByteInSatoshi: number;
508
512
  feePaidBy: FeePaidByEnum;
509
513
  discardChange?: boolean;
514
+ walletCache?: WalletCache;
510
515
  }) {
511
516
  // build transaction
512
517
  if (utxos) {
@@ -515,15 +520,17 @@ export async function getFeeAmount({
515
520
  await buildEncodedTransaction({
516
521
  inputs: utxos,
517
522
  outputs: sendRequests,
518
- signingKey: privateKey,
519
- sourceAddress,
520
- fee: 0, //DUST_UTXO_THRESHOLD
523
+ signingKey: placeholderPrivateKeyBin,
524
+ fee: 0n, //DUST_UTXO_THRESHOLD
521
525
  discardChange: discardChange ?? false,
522
526
  feePaidBy,
523
527
  changeAddress: "",
528
+ walletCache,
524
529
  });
525
530
 
526
- return Math.ceil(draftTransaction.length * relayFeePerByteInSatoshi + 1);
531
+ return BigInt(
532
+ Math.ceil(draftTransaction.length * relayFeePerByteInSatoshi + 1)
533
+ );
527
534
  } else {
528
535
  throw Error(
529
536
  "The available inputs in the wallet cannot satisfy this send request"
@@ -536,32 +543,32 @@ export async function buildEncodedTransaction({
536
543
  inputs,
537
544
  outputs,
538
545
  signingKey,
539
- sourceAddress,
540
- fee = 0,
546
+ fee = 0n,
541
547
  discardChange = false,
542
548
  feePaidBy = FeePaidByEnum.change,
543
549
  changeAddress = "",
544
550
  buildUnsigned = false,
551
+ walletCache,
545
552
  }: {
546
- inputs: UtxoI[];
553
+ inputs: Utxo[];
547
554
  outputs: Array<SendRequest | TokenSendRequest | OpReturnData>;
548
555
  signingKey: Uint8Array;
549
- sourceAddress: string;
550
- fee?: number;
556
+ fee?: bigint;
551
557
  discardChange?: boolean;
552
558
  feePaidBy?: FeePaidByEnum;
553
559
  changeAddress?: string;
554
560
  buildUnsigned?: boolean;
561
+ walletCache?: WalletCache;
555
562
  }) {
556
563
  const { transaction, sourceOutputs } = await buildP2pkhNonHdTransaction({
557
564
  inputs,
558
565
  outputs,
559
566
  signingKey,
560
- sourceAddress,
561
567
  fee,
562
568
  discardChange,
563
569
  feePaidBy,
564
570
  changeAddress,
571
+ walletCache,
565
572
  });
566
573
 
567
574
  if (buildUnsigned === true) {
@@ -592,7 +599,7 @@ export async function signUnsignedTransaction(
592
599
  throw new Error("Transaction template error");
593
600
  }
594
601
 
595
- const compiler = walletTemplateToCompilerBCH(template);
602
+ const compiler = walletTemplateToCompilerBch(template);
596
603
  const transactionTemplate: Readonly<
597
604
  TransactionTemplateFixed<typeof compiler>
598
605
  > = { ...decoded };