@ledgerhq/hw-app-btc 6.9.1-taproot.0 → 6.11.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 (133) hide show
  1. package/README.md +602 -107
  2. package/lib/Btc.d.ts +11 -7
  3. package/lib/Btc.d.ts.map +1 -1
  4. package/lib/Btc.js +113 -31
  5. package/lib/Btc.js.map +1 -1
  6. package/lib/BtcNew.d.ts +81 -32
  7. package/lib/BtcNew.d.ts.map +1 -1
  8. package/lib/BtcNew.js +296 -99
  9. package/lib/BtcNew.js.map +1 -1
  10. package/lib/BtcOld.d.ts +3 -1
  11. package/lib/BtcOld.d.ts.map +1 -1
  12. package/lib/BtcOld.js +22 -6
  13. package/lib/BtcOld.js.map +1 -1
  14. package/lib/constants.d.ts +1 -0
  15. package/lib/constants.d.ts.map +1 -1
  16. package/lib/constants.js +2 -1
  17. package/lib/constants.js.map +1 -1
  18. package/lib/getAppAndVersion.d.ts +3 -2
  19. package/lib/getAppAndVersion.d.ts.map +1 -1
  20. package/lib/getAppAndVersion.js.map +1 -1
  21. package/lib/newops/appClient.d.ts +6 -2
  22. package/lib/newops/appClient.d.ts.map +1 -1
  23. package/lib/newops/appClient.js +9 -5
  24. package/lib/newops/appClient.js.map +1 -1
  25. package/lib/newops/clientCommands.d.ts +18 -2
  26. package/lib/newops/clientCommands.d.ts.map +1 -1
  27. package/lib/newops/clientCommands.js +20 -3
  28. package/lib/newops/clientCommands.js.map +1 -1
  29. package/lib/newops/merkelizedPsbt.d.ts +11 -0
  30. package/lib/newops/merkelizedPsbt.d.ts.map +1 -1
  31. package/lib/newops/merkelizedPsbt.js +11 -0
  32. package/lib/newops/merkelizedPsbt.js.map +1 -1
  33. package/lib/newops/merkle.d.ts +5 -0
  34. package/lib/newops/merkle.d.ts.map +1 -1
  35. package/lib/newops/merkle.js +5 -0
  36. package/lib/newops/merkle.js.map +1 -1
  37. package/lib/newops/merkleMap.d.ts +10 -0
  38. package/lib/newops/merkleMap.d.ts.map +1 -1
  39. package/lib/newops/merkleMap.js +10 -0
  40. package/lib/newops/merkleMap.js.map +1 -1
  41. package/lib/newops/policy.d.ts +8 -0
  42. package/lib/newops/policy.d.ts.map +1 -1
  43. package/lib/newops/policy.js +9 -1
  44. package/lib/newops/policy.js.map +1 -1
  45. package/lib/newops/psbtExtractor.d.ts +6 -0
  46. package/lib/newops/psbtExtractor.d.ts.map +1 -1
  47. package/lib/newops/psbtExtractor.js +6 -0
  48. package/lib/newops/psbtExtractor.js.map +1 -1
  49. package/lib/newops/psbtFinalizer.d.ts +11 -1
  50. package/lib/newops/psbtFinalizer.d.ts.map +1 -1
  51. package/lib/newops/psbtFinalizer.js +28 -4
  52. package/lib/newops/psbtFinalizer.js.map +1 -1
  53. package/lib/newops/psbtv2.d.ts +22 -2
  54. package/lib/newops/psbtv2.d.ts.map +1 -1
  55. package/lib/newops/psbtv2.js +37 -8
  56. package/lib/newops/psbtv2.js.map +1 -1
  57. package/lib-es/Btc.d.ts +11 -7
  58. package/lib-es/Btc.d.ts.map +1 -1
  59. package/lib-es/Btc.js +94 -31
  60. package/lib-es/Btc.js.map +1 -1
  61. package/lib-es/BtcNew.d.ts +81 -32
  62. package/lib-es/BtcNew.d.ts.map +1 -1
  63. package/lib-es/BtcNew.js +293 -101
  64. package/lib-es/BtcNew.js.map +1 -1
  65. package/lib-es/BtcOld.d.ts +3 -1
  66. package/lib-es/BtcOld.d.ts.map +1 -1
  67. package/lib-es/BtcOld.js +22 -6
  68. package/lib-es/BtcOld.js.map +1 -1
  69. package/lib-es/constants.d.ts +1 -0
  70. package/lib-es/constants.d.ts.map +1 -1
  71. package/lib-es/constants.js +1 -0
  72. package/lib-es/constants.js.map +1 -1
  73. package/lib-es/getAppAndVersion.d.ts +3 -2
  74. package/lib-es/getAppAndVersion.d.ts.map +1 -1
  75. package/lib-es/getAppAndVersion.js.map +1 -1
  76. package/lib-es/newops/appClient.d.ts +6 -2
  77. package/lib-es/newops/appClient.d.ts.map +1 -1
  78. package/lib-es/newops/appClient.js +9 -5
  79. package/lib-es/newops/appClient.js.map +1 -1
  80. package/lib-es/newops/clientCommands.d.ts +18 -2
  81. package/lib-es/newops/clientCommands.d.ts.map +1 -1
  82. package/lib-es/newops/clientCommands.js +20 -3
  83. package/lib-es/newops/clientCommands.js.map +1 -1
  84. package/lib-es/newops/merkelizedPsbt.d.ts +11 -0
  85. package/lib-es/newops/merkelizedPsbt.d.ts.map +1 -1
  86. package/lib-es/newops/merkelizedPsbt.js +11 -0
  87. package/lib-es/newops/merkelizedPsbt.js.map +1 -1
  88. package/lib-es/newops/merkle.d.ts +5 -0
  89. package/lib-es/newops/merkle.d.ts.map +1 -1
  90. package/lib-es/newops/merkle.js +5 -0
  91. package/lib-es/newops/merkle.js.map +1 -1
  92. package/lib-es/newops/merkleMap.d.ts +10 -0
  93. package/lib-es/newops/merkleMap.d.ts.map +1 -1
  94. package/lib-es/newops/merkleMap.js +10 -0
  95. package/lib-es/newops/merkleMap.js.map +1 -1
  96. package/lib-es/newops/policy.d.ts +8 -0
  97. package/lib-es/newops/policy.d.ts.map +1 -1
  98. package/lib-es/newops/policy.js +10 -2
  99. package/lib-es/newops/policy.js.map +1 -1
  100. package/lib-es/newops/psbtExtractor.d.ts +6 -0
  101. package/lib-es/newops/psbtExtractor.d.ts.map +1 -1
  102. package/lib-es/newops/psbtExtractor.js +6 -0
  103. package/lib-es/newops/psbtExtractor.js.map +1 -1
  104. package/lib-es/newops/psbtFinalizer.d.ts +11 -1
  105. package/lib-es/newops/psbtFinalizer.d.ts.map +1 -1
  106. package/lib-es/newops/psbtFinalizer.js +28 -4
  107. package/lib-es/newops/psbtFinalizer.js.map +1 -1
  108. package/lib-es/newops/psbtv2.d.ts +22 -2
  109. package/lib-es/newops/psbtv2.d.ts.map +1 -1
  110. package/lib-es/newops/psbtv2.js +37 -8
  111. package/lib-es/newops/psbtv2.js.map +1 -1
  112. package/package.json +4 -4
  113. package/src/Btc.ts +92 -21
  114. package/src/BtcNew.ts +295 -77
  115. package/src/BtcOld.ts +13 -9
  116. package/src/bip32.ts +1 -1
  117. package/src/constants.ts +1 -0
  118. package/src/getAppAndVersion.ts +7 -4
  119. package/src/newops/appClient.ts +13 -5
  120. package/src/newops/clientCommands.ts +19 -3
  121. package/src/newops/merkelizedPsbt.ts +11 -0
  122. package/src/newops/merkle.ts +5 -0
  123. package/src/newops/merkleMap.ts +10 -0
  124. package/src/newops/policy.ts +10 -2
  125. package/src/newops/psbtExtractor.ts +6 -0
  126. package/src/newops/psbtFinalizer.ts +28 -4
  127. package/src/newops/psbtv2.ts +38 -14
  128. package/tests/Btc.integration.test.ts +125 -15
  129. package/tests/Btc.test.ts +83 -0
  130. package/tests/newops/BtcNew.test.ts +75 -508
  131. package/tests/newops/integrationtools.ts +174 -0
  132. package/tests/newops/testtx.ts +676 -0
  133. package/tests/speculosclient.ts +47 -0
@@ -1,25 +1,16 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
- /* eslint-disable prettier/prettier */
3
- import {
4
- openTransportReplayer,
5
- RecordStore
6
- } from "@ledgerhq/hw-transport-mocker";
2
+ import { openTransportReplayer, RecordStore } from "@ledgerhq/hw-transport-mocker";
7
3
  import { TransportReplayer } from "@ledgerhq/hw-transport-mocker/lib/openTransportReplayer";
8
- import bs58check from "bs58check";
9
4
  import ecc from "tiny-secp256k1";
10
5
  import { getXpubComponents, pathArrayToString } from "../../src/bip32";
11
- import Btc from "../../src/Btc";
12
6
  import BtcNew from "../../src/BtcNew";
13
- import { BufferWriter } from "../../src/buffertools";
14
- import { CreateTransactionArg } from "../../src/createTransaction";
15
- import { AppClient } from "../../src/newops/appClient";
16
- import { AddressFormat } from "../../src/getWalletPublicKey";
17
7
  import {
18
8
  DefaultDescriptorTemplate,
19
9
  WalletPolicy
20
10
  } from "../../src/newops/policy";
21
11
  import { PsbtV2 } from "../../src/newops/psbtv2";
22
- import { Transaction } from "../../src/types";
12
+ import { AccountType, addressFormatFromDescriptorTemplate, creatDummyXpub, masterFingerprint, runSignTransaction, TestingClient } from "./integrationtools";
13
+ import { CoreInput, CoreTx, p2pkh, p2tr, p2wpkh, wrappedP2wpkh, wrappedP2wpkhTwoInputs } from "./testtx";
23
14
 
24
15
  test("getWalletPublicKey p2pkh", async () => {
25
16
  await testGetWalletPublicKey("m/44'/1'/0'", "pkh(@0)");
@@ -49,158 +40,66 @@ test("getWalletXpub normal path", async () => {
49
40
  await testGetWalletXpub("m/44'/0'/0'");
50
41
  });
51
42
 
43
+ function testPaths(type: AccountType): { ins: string[], out?: string } {
44
+ const basePath = `m/${type}/1'/0'/`;
45
+ const ins = [
46
+ basePath + "0/0",
47
+ basePath + "1/0",
48
+ basePath + "0/1",
49
+ basePath + "1/1",
50
+ basePath + "0/2",
51
+ basePath + "1/2",
52
+ ];
53
+ return { ins };
54
+ }
55
+
52
56
  test("Sign p2pkh", async () => {
53
- await runSignTransactionTest(p2pkh);
57
+ const changePubkey = "037ed58c914720772c59f7a1e7e76fba0ef95d7c5667119798586301519b9ad2cf";
58
+ await runSignTransactionTest(p2pkh, AccountType.p2pkh, changePubkey);
54
59
  });
55
60
  test("Sign p2wpkh wrapped", async () => {
56
- await runSignTransactionTest(wrappedP2wpkh);
57
- await runSignTransactionTest(wrappedP2wpkhTwoInputs);
61
+ let changePubkey = "03efc6b990c1626d08bd176aab0e545a4f55c627c7ddee878d12bbbc46a126177a";
62
+ await runSignTransactionTest(wrappedP2wpkh, AccountType.p2wpkhInP2sh, changePubkey);
63
+ changePubkey = "031175a985c56e310ce3496a819229b427a2172920fd20b5972dda62758c6def09";
64
+ await runSignTransactionTest(wrappedP2wpkhTwoInputs, AccountType.p2wpkhInP2sh, changePubkey);
58
65
  });
59
66
  test("Sign p2wpkh", async () => {
60
- await runSignTransactionTest(p2wpkh);
61
- await runSignTransactionTest(p2wpkhTwoInputs);
67
+ await runSignTransactionTest(p2wpkh, AccountType.p2wpkh);
62
68
  });
63
69
  test("Sign p2tr", async () => {
64
- await runSignTransactionTest(p2tr);
70
+ // This tx uses locktime, so this test verifies that locktime is propagated to/from
71
+ // the psbt correctly.
72
+ await runSignTransactionTest(p2tr, AccountType.p2tr);
65
73
  });
66
74
 
67
- async function runSignTransactionTest(testTx: CoreTx) {
68
- const [client, transport] = await createClient();
69
- const btcNew = new BtcNew(client);
70
- // btc is needed to perform some functions like splitTransaction.
71
- const btc = new Btc(transport);
72
- const accountType = getAccountType(testTx.vin[0], btc);
73
- const additionals: string[] = [];
74
- if (accountType == AccountType.p2wpkh) {
75
- additionals.push("bech32");
76
- }
77
- if (accountType == AccountType.p2tr) {
78
- additionals.push("bech32m");
79
- }
80
- const associatedKeysets: string[] = [];
81
- const accountXpub = "tpubDCwYjpDhUdPGP5rS3wgNg13mTrrjBuG8V9VpWbyptX6TRPbNoZVXsoVUSkCjmQ8jJycjuDKBb9eataSymXakTTaGifxR6kmVsfFehH1ZgJT";
82
- client.mockGetPubkeyResponse(`m/${accountType}/1'/0'`, accountXpub);
83
- const yieldSigs = new Map<number, Buffer>();
84
- const inputs = testTx.vin.map((input, index) => {
85
- const path = `m/${accountType}/1'/0'/${index % 2}/${index}`;
86
- associatedKeysets.push(path);
87
- const inputData = createInput(input, btc);
88
- const pubkey = getPubkey(index, accountType, testTx, inputData[0], inputData[1]);
89
- const mockXpub = creatDummyXpub(pubkey);
90
- client.mockGetPubkeyResponse(path, mockXpub);
91
- yieldSigs.set(index, getSignature(input, accountType));
92
- return inputData;
93
- });
94
- client.mockSignPsbt(yieldSigs);
95
- const outputWriter = new BufferWriter();
96
- outputWriter.writeVarInt(testTx.vout.length);
97
- testTx.vout.forEach((output) => {
98
- outputWriter.writeUInt64(BigInt(Number.parseFloat((output.value * 100000000).toFixed(8))));
99
- outputWriter.writeVarSlice(Buffer.from(output.scriptPubKey.hex, "hex"));
100
- });
101
- const outputScriptHex = outputWriter.buffer().toString("hex");
102
-
103
- const arg: CreateTransactionArg = {
104
- inputs,
105
- additionals,
106
- associatedKeysets,
107
- changePath: `m/${accountType}/1'/0'/1/100`,
108
- outputScriptHex,
109
- lockTime: testTx.locktime,
110
- segwit: accountType != AccountType.p2pkh,
111
- };
112
- client.mockGetPubkeyResponse(arg.changePath!, creatDummyXpub(Buffer.alloc(32, 0)));
113
- const tx = await btcNew.createPaymentTransactionNew(arg);
75
+ test("Sign p2tr with sigHashType", async () => {
76
+ const testTx = JSON.parse(JSON.stringify(p2tr));
77
+ testTx.vin.forEach((input: CoreInput, index: number) => {
78
+ // Test SIGHASH_SINGLE | SIGHASH_ANYONECANPAY, 0x83
79
+ const sig = input.txinwitness![0] + "83";
80
+ input.txinwitness = [sig];
81
+ })
82
+ const tx = await runSignTransactionNoVerification(testTx, AccountType.p2tr);
83
+ // The verification of the sighashtype is done in MockClient.signPsbt
84
+ })
85
+
86
+ async function runSignTransactionTest(testTx: CoreTx, accountType: AccountType, changePubkey?: string) {
87
+ const tx = await runSignTransactionNoVerification(testTx, accountType, changePubkey);
114
88
  expect(tx).toEqual(testTx.hex);
115
- };
116
-
117
- function addressFormatFromDescriptorTemplate(descTemp: DefaultDescriptorTemplate): AddressFormat {
118
- if (descTemp == "tr(@0)") return "bech32m";
119
- if (descTemp == "pkh(@0)") return "legacy";
120
- if (descTemp == "wpkh(@0)") return "bech32";
121
- if (descTemp == "sh(wpkh(@0))") return "p2sh";
122
- throw new Error();
123
- }
124
-
125
- enum AccountType {
126
- p2tr = "86'",
127
- p2wpkh = "84'",
128
- p2wpkhInP2sh = "49'",
129
- p2pkh = "44'"
130
89
  }
131
90
 
132
- function getPubkey(inputIndex: number, accountType: AccountType, testTx: CoreTx, spentTx: Transaction, spentOutputIndex: number): Buffer {
133
- const scriptSig = Buffer.from(testTx.vin[inputIndex].scriptSig.hex, "hex");
134
- if (accountType == AccountType.p2pkh) {
135
- return scriptSig.slice(scriptSig.length-33);
136
- }
137
- if (accountType == AccountType.p2tr) {
138
- return spentTx.outputs![spentOutputIndex].script.slice(2, 34); // 32 bytes x-only pubkey
139
- }
140
- if (accountType == AccountType.p2wpkh || accountType == AccountType.p2wpkhInP2sh) {
141
- return Buffer.from(testTx.vin[inputIndex].txinwitness![1], "hex");
142
- }
143
- throw new Error();
144
- }
145
-
146
- function getSignature(testTxInput: CoreInput, accountType: AccountType): Buffer {
147
- const scriptSig = Buffer.from(testTxInput.scriptSig.hex, "hex");
148
- if (accountType == AccountType.p2pkh) {
149
- return scriptSig.slice(1, scriptSig.length-34);
150
- }
151
- if (accountType == AccountType.p2tr) {
152
- return Buffer.from(testTxInput.txinwitness![0], "hex");
153
- }
154
- if (accountType == AccountType.p2wpkh || accountType == AccountType.p2wpkhInP2sh) {
155
- return Buffer.from(testTxInput.txinwitness![0], "hex");
156
- }
157
- throw new Error();
158
- }
159
-
160
- function getAccountType(coreInput: CoreInput, btc: Btc): AccountType {
161
- const spentTx = spentTxs[coreInput.txid];
162
- if (!spentTx) {
163
- throw new Error("Spent tx " + coreInput.txid + " unavailable.");
164
- }
165
- const splitSpentTx = btc.splitTransaction(spentTx, !!coreInput.txinwitness);
166
- const spentOutput = splitSpentTx.outputs![coreInput.vout];
167
- const script = spentOutput.script;
168
- if (script.length == 34 && script[0] == 0x51) {
169
- return AccountType.p2tr;
170
- }
171
- if (script.length == 22 && script[0] == 0x00) {
172
- return AccountType.p2wpkh;
173
- }
174
- if (script.length == 23) {
175
- return AccountType.p2wpkhInP2sh;
176
- }
177
- return AccountType.p2pkh;
178
- }
179
-
180
- function creatDummyXpub(pubkey: Buffer): string {
181
- const xpubDecoded = bs58check.decode("tpubDHcN44A4UHqdHJZwBxgTbu8Cy87ZrZkN8tQnmJGhcijHqe4rztuvGcD4wo36XSviLmiqL5fUbDnekYaQ7LzAnaqauBb9RsyahsTTFHdeJGd");
182
- const pubkey33 = pubkey.length == 33 ? pubkey : Buffer.concat([Buffer.of(2), pubkey]);
183
- xpubDecoded.fill(pubkey33, xpubDecoded.length-33);
184
- return bs58check.encode(xpubDecoded);
185
- }
186
-
187
- function createInput(coreInput: CoreInput, btc: Btc): [Transaction, number, string, number] {
188
- const spentTx = spentTxs[coreInput.txid];
189
- if (!spentTx) {
190
- throw new Error("Spent tx " + coreInput.txid + " unavailable.");
191
- }
192
- const splitSpentTx = btc.splitTransaction(spentTx, !!coreInput.txinwitness);
193
- const scriptSig = coreInput.scriptSig;
194
- let redeemScript;
195
- if (scriptSig?.hex && scriptSig.hex.startsWith("160014")) {
196
- redeemScript = scriptSig.hex.substring(2);
197
- }
198
- return [splitSpentTx, coreInput.vout, redeemScript, coreInput.sequence];
199
- }
200
-
201
- async function createClient(): Promise<[MockClient, TransportReplayer]> {
202
- const transport = await openTransportReplayer(RecordStore.fromString(""));
203
- return [new MockClient(transport), transport];
91
+ async function runSignTransactionNoVerification(testTx: CoreTx, accountType: AccountType, changePubkey?: string): Promise<string> {
92
+ const [client, transport] = await createClient();
93
+ const accountXpub = "tpubDCwYjpDhUdPGP5rS3wgNg13mTrrjBuG8V9VpWbyptX6TRPbNoZVXsoVUSkCjmQ8jJycjuDKBb9eataSymXakTTaGifxR6kmVsfFehH1ZgJT";
94
+ client.mockGetPubkeyResponse(`m/${accountType}/1'/0'`, accountXpub);
95
+ const paths = testPaths(accountType);
96
+ if (changePubkey) {
97
+ paths.out = `m/${accountType}/1'/0'` + "/1/3";
98
+ client.mockGetPubkeyResponse(paths.out, creatDummyXpub(Buffer.from(changePubkey, "hex")));
99
+ }
100
+ const tx = await runSignTransaction(testTx, paths, client, transport);
101
+ await transport.close();
102
+ return tx;
204
103
  }
205
104
 
206
105
  async function testGetWalletXpub(path: string, version = 0x043587cf) {
@@ -208,7 +107,7 @@ async function testGetWalletXpub(path: string, version = 0x043587cf) {
208
107
  const expectedXpub = "tpubDCwYjpDhUdPGP5rS3wgNg13mTrrjBuG8V9VpWbyptX6TRPbNoZVXsoVUSkCjmQ8jJycjuDKBb9eataSymXakTTaGifxR6kmVsfFehH1ZgJT";
209
108
  client.mockGetPubkeyResponse(path, expectedXpub);
210
109
  const btc = new BtcNew(client);
211
- const result = await btc.getWalletXpub({path: path, xpubVersion: version});
110
+ const result = await btc.getWalletXpub({ path: path, xpubVersion: version });
212
111
  expect(result).toEqual(expectedXpub);
213
112
  }
214
113
  async function testGetWalletPublicKey(
@@ -235,7 +134,7 @@ async function testGetWalletPublicKey(
235
134
 
236
135
  const btcNew = new BtcNew(client);
237
136
  const addressFormat = addressFormatFromDescriptorTemplate(expectedDescriptorTemplate);
238
- const result = await btcNew.getWalletPublicKey(path, {format: addressFormat});
137
+ const result = await btcNew.getWalletPublicKey(path, { format: addressFormat });
239
138
  verifyGetWalletPublicKeyResult(result, keyXpub, "testaddress");
240
139
 
241
140
  const resultAccount = await btcNew.getWalletPublicKey(accountPath);
@@ -259,8 +158,12 @@ function verifyGetWalletPublicKeyResult(
259
158
  expect(result.publicKey).toEqual(expectedPubKey.toString("hex"));
260
159
  }
261
160
 
262
- const masterFingerprint = Buffer.of(1, 2, 3, 4);
263
- class MockClient extends AppClient {
161
+ export async function createClient(): Promise<[MockClient, TransportReplayer]> {
162
+ const transport = await openTransportReplayer(RecordStore.fromString(""));
163
+ return [new MockClient(transport), transport];
164
+ }
165
+
166
+ class MockClient extends TestingClient {
264
167
  getPubkeyResponses = new Map();
265
168
  getWalletAddressResponses = new Map();
266
169
  yieldSigs: Map<number, Buffer>[] = [];
@@ -279,7 +182,7 @@ class MockClient extends AppClient {
279
182
  mockSignPsbt(yieldSigs: Map<number, Buffer>) {
280
183
  this.yieldSigs.push(yieldSigs);
281
184
  }
282
- async getPubkey(display: boolean, pathElements: number[]): Promise<string> {
185
+ async getExtendedPubkey(display: boolean, pathElements: number[]): Promise<string> {
283
186
  const path = pathArrayToString(pathElements);
284
187
  const response = this.getPubkeyResponses.get(path);
285
188
  if (!response) {
@@ -307,11 +210,23 @@ class MockClient extends AppClient {
307
210
  return masterFingerprint;
308
211
  }
309
212
  async signPsbt(
310
- _psbt: PsbtV2,
213
+ psbt: PsbtV2,
311
214
  _walletPolicy: WalletPolicy,
312
- _walletHMAC: Buffer | null
215
+ _walletHMAC: Buffer | null,
313
216
  ): Promise<Map<number, Buffer>> {
314
- return this.yieldSigs.splice(0, 1)[0];
217
+ const sigs = this.yieldSigs.splice(0, 1)[0];
218
+ const sig0 = sigs.get(0)!;
219
+ if (sig0.length == 64) {
220
+ // Taproot may leave out sighash type, which defaults to 0x01 SIGHASH_ALL
221
+ return sigs;
222
+ }
223
+ const sigHashType = sig0.readUInt8(sig0.length - 1);
224
+ if (sigHashType != 0x01) {
225
+ for (let i = 0; i < psbt.getGlobalInputCount(); i++) {
226
+ expect(psbt.getInputSighashType(i)).toEqual(sigHashType);
227
+ }
228
+ }
229
+ return sigs;
315
230
  }
316
231
  private getWalletAddressKey(
317
232
  walletPolicy: WalletPolicy,
@@ -322,351 +237,3 @@ class MockClient extends AppClient {
322
237
  }
323
238
  }
324
239
 
325
- /*
326
- To find example transactions:
327
- for h in `./bitcoin-cli getblock 00000000025a711e6cd4bce9138dc852232a4494afbf36d8bb80499a786da2a4|jq '.tx[]'`; do ./bitcoin-cli getrawtransaction `echo $h | sed 's/"//g'` 1; done > 00000000025a711e6cd4bce9138dc852232a4494afbf36d8bb80499a786da2a4
328
- */
329
- type CoreInput = {txid: string, vout: number, scriptSig: {hex: string, [x: string]: unknown}, txinwitness?: string[], sequence: number}
330
- type CoreOutput = {value: number, scriptPubKey: {hex: string, [x: string]: unknown}, [x: string]: unknown}
331
- type CoreTx = {txid: string, vin: CoreInput[], vout: CoreOutput[], hex: string, locktime: number, [x: string]: unknown}
332
- const spentTxs = {
333
- "5c02391a5b8f55ebb0db0e4e75900ace70f7e8e992115b3931379ab32b69da40": "020000000001016dac615a27b99c5e82af284cc01b410e789047709de08026c861bb6675fbf81800000000171600140fc5a02184f752c41e7f5da947f48646a213e32dfeffffff02ab5b990000000000160014080b627107f555d511730262f3c7167168e0db46a086010000000000220020de4cbf3bfa733a93fc7db03ef7aef2d3aae4e6c04c0ed3a9ebfe6aae259bb7e8024730440220740e00a9cde06677429018b6cadadbdbe7edd2bcd20f8255be2d83560de1490b02206be17eb882b02b25db2367d3afe8b67e6fb62fee2cd8244285403f16efc1886c012103ad62cd5bce8dab660f74c6bdcd4fc2695acdaa3687d8d6901c1cfb35b1211f3b87032000",
334
- "80453b180c6616431d28d395a6a89cb331d7ecb21bf3ac1cbb68c90dba6e95ff": "02000000015e50f6bfe2d91dc2927ba425fd1617cc2b68d2d7d2b70a3c795c15a9c86f43f1010000006a47304402203c9bf4759c850c43d7c25936c4163a3e6b869cc8a4cce107475fb0447442814c02203630d862ad274ba227ddd8d7ca85580139398b53101d4c4eec9d54712bc4b0420121037ed58c914720772c59f7a1e7e76fba0ef95d7c5667119798586301519b9ad2cfffffffff020000000000000000366a34696f6e3a322e516d66316f75486a46474b48674652716262794a4463454c617369414c595a344d5769797542715877674376695494eded07000000001976a9147628046f6ec479c031d03a47b6a003c4dedb1cad88ac00000000",
335
- "0d41be343ced2023ff112b123a7bb5c8f345becddb8f1cc7070e1273a21d3710": "0200000000010112fad068799db7637882b643557fb48fd5a7d733276a0e8e96cb44c28e3633230100000000fdffffff01b23f010000000000225120aaeed4185487b0fa6939914cf851cfbe84f5ef098bdc79408e8201b98339a0d80400473044022037ac3cbec286964f3fda9fdd4a73e510d76e829b267aafab392ee23b72d888f602200cc2f93f9251efd6ff1d511384fd0f7d0eb62924444f3806c5ac5e82977e546f0147304402203d5f1ef5cf53bce95e10731375b625dbaf4f6a344cb858d203b422aa421e59e902206fab1e6ee80420a46b5bafbf5ceecd06fd0971080b4c3d0c69d24f953f30ce160169522102bec882e74ae50d719b95087050feb223d9af025d381700c02eb27e8efc5aa50d21038be5e2af3e885abb51d4bd2dbe7bde16d24e1bc3fbe74781ff09645786c7cc262103b135afbeb5dd40aab1fd5e0b19aa537713af8507f01cbfc123a21a750e0efd8753aeb1f61f00",
336
- "5742c24f1485958d0e36d0ae758b1e33c01ba99107eb54baa539cc7db233a330": "02000000000101b7ff921fcf988d2f394b23f7a9e4648a11e64040d9cbe140d68e9f0fa63b52bd00000000171600142d62a39a40a30228c77de441c1f0993fe1707ddaffffffff02c38f934c0200000017a9145a102ac5376429003168cad88c80331daa3a747187102700000000000017a914c18c7cc194e62a004de3427199417f42d32cd81b870247304402205b615920b281070e99804ef9c5fe57e0595cb0c7968dd5d803cc505f7d28413102202b51ebf4ba70d7f987a98d101e1d60a6b40fba5bcb6ba9261eca9ed3777761cd012103efc6b990c1626d08bd176aab0e545a4f55c627c7ddee878d12bbbc46a126177a00000000",
337
- "9075ef8fd97f92ff0db344322873f12c42b29661c3960801e05114ba8adcabd6": "0200000000010f92d11e34e34bbb29ddd104b898afd9a3d5898fda185788aa050dabe5de7e380c010000001716001438b60e46e50c1d9ecdf529f6861053ceb7ae704bfdffffff5a17b47e858b5e1bb93e0d537ce3ae81e961f67738d8b6eb6b9262e0eb37c6d3000000001716001400dfc989afe93cffcfdab699dd5444499e556219fdffffffabc944185705072eb219ec78224cc952a4518b5db3a48d640f474f078726d41e01000000171600149a72a581de0529c01c1be5f9da4c5a57266e8265fdffffffd18c7593bd84acf021960a32b51892bc900f68439b9db3585468d48353f3cd1b00000000171600146a072874debcfb08fd5d3e857464aaccc330b8bbfdffffff6690ca0cc641a3fbb62c91293cf11f3157a756427dcf8f9f98d36863a8b2631d000000001716001444089e785379c76f81236e908eacf20402f75f3bfdffffff507f7282a896d1a937c9cee20b16865178bce8d2ccd96d87275b926da677bf8d010000001716001400dfc989afe93cffcfdab699dd5444499e556219fdffffff8c32212f7669800b4c885102df7fa2c58f9da5081eedc12a95807e2753aad0a10000000017160014b939091b7a8fb7f4f4baf61617459fd6a59aac5afdffffff83e6be309de96822dcfa0485255a2232d268049874f4ce1f0316f3074ddfc82d0000000017160014b939091b7a8fb7f4f4baf61617459fd6a59aac5afdfffffff8fa8bbe65f17f240d4bdc7988f66d62d3feb9c5c30f65afdb7cbfe4dc1d897b000000001716001456c66c89e5b3f75b07d3dad4544a00c4c9cfd3a9fdffffffbc1e1066934b242cfaf510b2e36a79b94a0ba0816f897376c8e528377277aebd0000000017160014b939091b7a8fb7f4f4baf61617459fd6a59aac5afdffffff8d12f2196ad8d4492299367989c22c724e0a7d40ab436246847f5d7aab5451c10000000017160014c46b16332c7e7dc1a3700c0513b11de7ddb61eeefdfffffff16da2923302a6ec1406c568952189b0a2b7e45a58388b120965fac72ecd094c0000000017160014c040c70f9ddf7f1b07b0a51c42700919644760b1fdffffffdb11b85eed3aa6bdfd5215f96b5615a14b82f7dac6661f17ec56dcf55e993b2900000000171600142be8df852d88b2cd4027e11d6aa59ea60eabe41bfdffffffcb9e9d8a06acff88fc08f95c21a099b836ed0cd147bcb9e2b88925dc3b481c48000000001716001444089e785379c76f81236e908eacf20402f75f3bfdffffff9ba7464f96b053e164646bfd6b68aa4856d40fc904b77725f926ce658469866f0100000017160014c040c70f9ddf7f1b07b0a51c42700919644760b1fdffffff02e8c41b000000000017a914cbe0cfb39915c0bde11f8140250bdb5d93b2bbb08796f01c060000000017a914369871cf149aafed693a072dc7ece6e4d7ee04a08702473044022017f230ccfdd297a958f78e9ca30687f75272d21fd4dd8ab081f026345f153f9a02207e82078c617b9d1049a81b244ea77699dbba80eabd3103f838d26272687c7b37012103ca50097890e10ff8d838c35f9438b99195e472927b9557726cdfe6ecb1f5566202483045022100c1b180460ded0e5cd3b834eca02640aee098ff00b73f749eaaa6d9b84795edeb02205373f2a236734d2b96e0ed9dae6994e553308bb0e88a7c1dbf1d8ce58b83f95e012103ff28dd4d0ae2c738fc76fd056508f9e498bc7b0de6e78bcd18183214095dcbde0248304502210085e873602054bce661e8029524776e4b6d4f07b560ffa386582d856f3cf05e5802202e99b7f099fc49ff6659aaa2954c9e73add7b61e844b8fce5e9305f071bdd4600121036d65f9fff32f527ef6d95b4fb27b1c49e9e922c6386dcd9bd887c6569d2ee5f002483045022100c140d8350706d222cc501b2aeebfd9931d1312dffd88ed3dc8db03a3b62c9a10022037fbe9fa2d8dc17262e662f313b5377a18cf7e96c74530fa51641febd45a2f1f0121025b56f912f06420cf05dde62a1ff3be9d45cee1ba910682f10a7febad7960412e0247304402207dc275a40b6946095221386838a82048f728989049b3a190f6217a0ff29ed79602202613a0d525b42d179bb8ad12eb3abf9b81e9acbea108f85e8c474392eea87bf2012102075108f2dcd417fdddaa1ccaee42fa90cf7ef18dbae6f3a29d282cb645dfd4840247304402202a79e66ab8c071af688d5d0183e18147d4c9c01170a488635e7eee88a572d774022020dc6bf064031742cf6ca42576d7848444505eaf6ccac689b76658526ad2ddc6012103ff28dd4d0ae2c738fc76fd056508f9e498bc7b0de6e78bcd18183214095dcbde024830450221009ff973377e49753848789dac6b0dac5f51a92acfe0fce1be620b8a7a9c11f69b022056884b948b58ad1ace8a85ed676f76ef6c06dd6a6fe2d717b1cb3cfed8f3851a01210274558f6cc837a6d3fac1b490101d9b7065c6cf6e2b1c0dc25d87e989a97c3f26024730440220207327234dde5b2553572d6daa692bd35c1977007bb20ffbf64f05d3ce92db1f02200d9593dac1a06326229ad1bc92badf0ca3b1d5263936f690cd03762510fdf4f101210274558f6cc837a6d3fac1b490101d9b7065c6cf6e2b1c0dc25d87e989a97c3f2602483045022100b52206df3697cbea5eb8c6e3b8331a3d36c4f3de6a2351bd140051360f2e8aa302203b0bfdab4147192fa2e5d7cce1476115dd751f1854a990afeb060f82c6f3265a01210391047b484be7081c3612493893d54edec45681674289cc7c9df675880dc6416b0247304402203408cab76d3bba6653471ffc3add53232f7bc320d0c24e76f5dd64e24e2801c7022004f82de281b9e634d3b50992d23d8116ca669befbc0eab4cb1eca5fd0b6bb4e001210274558f6cc837a6d3fac1b490101d9b7065c6cf6e2b1c0dc25d87e989a97c3f26024730440220469785ad4507c6ac92a572cbd5a863e19c2cf7bb383b9a03a1933b3f3f00a3df02205f280fa329adf7cfcc2b0b301f1a075d58c47ccdd7717fc7b6d82362b0adc32901210306d8b71d3612580f9a546e654a0150eb2556530250c6a36f50a2a519830f650302473044022075328b4cb0e9c9c39b344303195dd79f3b13906c2f1103a81fb77f5a6db2e235022046cdb5676617b1465abcca7a281ac3915e7de9ff2748eed0adb2b5b6e43041b0012103b34c36986c83afbbc234cf7e88f2717ea2a9c084c600e9ba2f11114940a7f9e80247304402205b4e682586ad51db67c9649552dd9e886b2e9493277a8696e530a2aa380ef0fe022074565b4b33c2153b9654b472ba9836ca824d2b31f1cc177a760745be5bd050b20121023be577036dac8d3e1d661d56589b7076712f2a44fd7d2c149fffcb999e64b58802483045022100f5e61765e412a1772d05fc1cea4b809aa60a2875ab727c7c8650f000948296720220386fbe042068e602cfed5f8d8f84d85b40912b5fbdd8af16b9682dd1b52788e6012102075108f2dcd417fdddaa1ccaee42fa90cf7ef18dbae6f3a29d282cb645dfd48402473044022059b33be7a9abea756630c74670900a32b7ee54c0e51d21e9628c23fddb3d0afe02204fe22442232f61db276cefea9665b7e164c84d5dbd6d53cc66fcc9a30e60c8b4012103b34c36986c83afbbc234cf7e88f2717ea2a9c084c600e9ba2f11114940a7f9e800000000",
338
- "5512d5788d4c26117f093de91223ef384c3fb22799810a92e3304bb6f0819224": "0200000000010145965c4228caf68517d945edd6011b9ed3acacc25e671d5ff17de63c3f0429bb0000000000feffffff02a4800cb3080000001600149102187fea0ada893fd32a7a823374ea81f428e8102700000000000017a91428b5e7e041bb35cc78793ff6741953a13090ab3d87024730440220303ff0212c80305b78651adf5f4d2de152f093b64afa4b0528f45d1864c2715302207ca67132b1cde92914d8a59664d8cd468358ed90ef7c6110d096d91e1cde02fc01210225682ef649fb604da92c7131baf6c5858b3f06d21e3b8f2d602bb488dbebf05e37052000",
339
- "d36d3ba59981dab0dad0e02dafa9fa97ad51f4e5a47ffad3ad8544bdb251b70f": "020000000001055aa7ebaae0ed0a026bf72011467deb0d21607714d1787d671a2457db72014267000000001716001463e4abed42b06909dc626f9f14e364d377e3e358fdffffff4fa37ac8b379296682cb4d529f6ea264e7e35c3f595c8c596692c91c0c85ddfd01000000171600147ac8f21860d4a529025b494597174eb1a441a57cfdffffff0c69fc1d2c9a3ae75004eaad986cad6b84a64db33913cb94103037f879da171c00000000171600146f6c84387636a119bdaf92cad81396c2ce7a4d58fdfffffff4640d1312f962506978643ccafb843f0230eb9583d9e9e505035b01bf0dc9720000000017160014fad372f775bbc24ab9a6ea3613a8ef81871f78b1fdffffff8c4ca258a1f248d19b0def11b5e046a3fe623c0d06e65c035f858ffcb267d05a0000000017160014f58147b16bf214794f87b534c00a680fe74135e5fdffffff0230341b000000000017a91443e08be49ad8303db84342b24e7ba49f6b0f487487fa1aa3010000000017a914c5c22cf7cccf3021156ddaded63559437c36fe2c8702483045022100d855db0fadb0d705356bf3d8ee333f3e563bff04cda0f56ff5c7b5c15e2c624602200b5db6961d6e8ceef87da9403305bd099ac3ddad0c9d99e2649dfebbc7242ee201210313092d082133d2219380f9f3829db3a0b177e33bb5e5a5b09d84db0969d2ca2a02483045022100b24f394ac5f7ec7270a03a8c20bb423a6bec4122d261c17bd6b1286e0a9706d402204d3158f865b93a54c0432f5d4ed2ce96ed04aa3ed8561eb60b0cdfedd02747de0121032e12e4ab6dcbca1e3aceaf0ce8621fb21571c067015e181f4b9ddfffc176182c0247304402200296b7f4c81291755b32d4c46b8765bdc4716afba20ba57fb51405a60826c1d002205fd1dbd492472e5754f43e19f224a8ec1c309024b012dbb84197817c844e25f8012102fb6077e1a918e96d2ac9301eeee5cd47929a340bf0639ff2ef0a4a55c743bbd3024830450221009089c07ee3e7232c30e1705c74d4f4e23fca2cb130765d7edc8de37f187e4f8202204f513450265596bd00c1271735f9bbdcc380564773881a4d2dd77d3f506855c7012103f001a06f9bbdbe1a479111232193479d4d1939039a25a678d82bd7b718501a7e024730440220073fb0fde51f53689429044c69758a4ca1963ac857114a4764679fe6197934a10220461aedccc59727a2efd0f8ca63b2f27187c2ca766274e499fb4ac500828c23b5012103147ad367eba82a193f79ed2ad8595ee2adcce26fdda1c2640707abfb9589abe900000000",
340
- "28ad5054e029252d72da37f13fce66212d7f7763845b4a8c4aaf78e897b2bf9f": "0200000000010129b8fe8705de9e342ab80e5ae4237f05dc467586c8d85fbeb29f750d670a849a0200000017160014c1ac0d63d0258ea1b6fe90ef72d0c35d8d773dd3feffffff030000000000000000166a146f6d6e6900000000800005dd00000017d784000097d31c000000000017a91428b5e7e041bb35cc78793ff6741953a13090ab3d871c0200000000000017a914693e66873dedeaed521e3d2dc646fccfdfa4f3978702473044022063e0349bbb6f6b5346bc12cc94289b3dfe3eedee21c03b9f52cef488ec5fe9e5022027f44fb819331ea3c97be06e85d46a797f91315626895c70fb9d2616a927cb1f012102fb255ed920db5c2f507289202eb60a160e5a067ee7e30199a4ed81b74c22e4412e052000",
341
- };
342
-
343
- // Taken from bitcoin-core testnet
344
- const p2tr: CoreTx = {
345
- "txid": "c77a7c5338ed59b934193209f16ea74ec6d846ef61e9fb9705d99e9896d79e25",
346
- "hash": "d5b0513aeb462fb52cf977a8d367021fa3e66002194a8b8dd2fe97e6e52b81e4",
347
- "version": 2,
348
- "size": 150,
349
- "vsize": 99,
350
- "weight": 396,
351
- "locktime": 2097065,
352
- "vin": [
353
- {
354
- "txid": "0d41be343ced2023ff112b123a7bb5c8f345becddb8f1cc7070e1273a21d3710",
355
- "vout": 0,
356
- "scriptSig": {
357
- "asm": "",
358
- "hex": ""
359
- },
360
- "txinwitness": [
361
- "8d370b53421e0ae033f736a73af72b35562b584143adca592fd918a0bb252ca904b379393446c8dddba08974a2122802844afcc03ef24bcb2312b81a5c5d65ac"
362
- ],
363
- "sequence": 4294967293
364
- }
365
- ],
366
- "vout": [
367
- {
368
- "value": 0.00081742,
369
- "n": 0,
370
- "scriptPubKey": {
371
- "asm": "0 f5d7911e8d7c560dfc3cf6e3079a4c7c0dce70e9",
372
- "hex": "0014f5d7911e8d7c560dfc3cf6e3079a4c7c0dce70e9",
373
- "reqSigs": 1,
374
- "type": "witness_v0_keyhash",
375
- "addresses": [
376
- "tb1q7htez85d03tqmlpu7m3s0xjv0sxuuu8fg40ght"
377
- ]
378
- }
379
- }
380
- ],
381
- "hex": "0200000000010110371da273120e07c71c8fdbcdbe45f3c8b57b3a122b11ff2320ed3c34be410d0000000000fdffffff014e3f010000000000160014f5d7911e8d7c560dfc3cf6e3079a4c7c0dce70e901408d370b53421e0ae033f736a73af72b35562b584143adca592fd918a0bb252ca904b379393446c8dddba08974a2122802844afcc03ef24bcb2312b81a5c5d65aca9ff1f00",
382
- "blockhash": "0000000000000024a3605855f3b669e9e165ab242e53761ecbaae4b6167829d3",
383
- "confirmations": 1017,
384
- "time": 1633037023,
385
- "blocktime": 1633037023
386
- };
387
-
388
- const p2wpkh = {
389
- "txid": "062c623b6a9486aaa11b60e5c37bddcd6214aa642172d81f485faf3b2fc2996e",
390
- "hash": "6fabbc622e0d8c9b099fce3a2ac92334a1902302f9f572525b563e3ad97aeab0",
391
- "version": 2,
392
- "size": 226,
393
- "vsize": 145,
394
- "weight": 577,
395
- "locktime": 2098057,
396
- "vin": [
397
- {
398
- "txid": "5c02391a5b8f55ebb0db0e4e75900ace70f7e8e992115b3931379ab32b69da40",
399
- "vout": 0,
400
- "scriptSig": {
401
- "asm": "",
402
- "hex": ""
403
- },
404
- "txinwitness": [
405
- "30440220667c54bc57770a563ef74e68331ee6a27d3a1b073d22e867fda346273d768da50220506609d58f78ab6dfe78d1635cf1974a234347f080da86ed1ee9b0ec345b7c1901",
406
- "02a236cce923cfb073fd4bfdaf0a8c5ae2f2144052a98549810cd3fe39dcf1e1d7"
407
- ],
408
- "sequence": 4294967294
409
- }
410
- ],
411
- "vout": [
412
- {
413
- "value": 0.09950330,
414
- "n": 0,
415
- "scriptPubKey": {
416
- "asm": "OP_HASH160 afe05670e110d5203e0544137d2ede18338ced8b OP_EQUAL",
417
- "hex": "a914afe05670e110d5203e0544137d2ede18338ced8b87",
418
- "reqSigs": 1,
419
- "type": "scripthash",
420
- "addresses": [
421
- "2N9HAz7E4itqt78dDkN2ZNkAYaKp1pmvnxH"
422
- ]
423
- }
424
- },
425
- {
426
- "value": 0.00100000,
427
- "n": 1,
428
- "scriptPubKey": {
429
- "asm": "OP_DUP OP_HASH160 c025f47a88d88b09aa9b4cb7f92010b1d513e300 OP_EQUALVERIFY OP_CHECKSIG",
430
- "hex": "76a914c025f47a88d88b09aa9b4cb7f92010b1d513e30088ac",
431
- "reqSigs": 1,
432
- "type": "pubkeyhash",
433
- "addresses": [
434
- "my2wW3Yic3huFYiHWSXy1sMX9DgeQRHmg9"
435
- ]
436
- }
437
- }
438
- ],
439
- "hex": "0200000000010140da692bb39a3731395b1192e9e8f770ce0a90754e0edbb0eb558f5b1a39025c0000000000feffffff027ad497000000000017a914afe05670e110d5203e0544137d2ede18338ced8b87a0860100000000001976a914c025f47a88d88b09aa9b4cb7f92010b1d513e30088ac024730440220667c54bc57770a563ef74e68331ee6a27d3a1b073d22e867fda346273d768da50220506609d58f78ab6dfe78d1635cf1974a234347f080da86ed1ee9b0ec345b7c19012102a236cce923cfb073fd4bfdaf0a8c5ae2f2144052a98549810cd3fe39dcf1e1d789032000",
440
- "blockhash": "0000000000000012201f4dd0b06cdbc3b8a037a5c2c0486c4523688555613a53",
441
- "confirmations": 16,
442
- "time": 1633594907,
443
- "blocktime": 1633594907
444
- };
445
-
446
- const wrappedP2wpkh: CoreTx = {
447
- "txid": "3f3b8e65eb666dc9950ddf1b4b9a7438e9baae710a6a7c06d2582bd2d750ed54",
448
- "hash": "a3035b0af8eb2176e4e4f459233c7e669e4a8becbf32cee7d1639ba52b671c5b",
449
- "version": 2,
450
- "size": 248,
451
- "vsize": 166,
452
- "weight": 662,
453
- "locktime": 0,
454
- "vin": [
455
- {
456
- "txid": "5742c24f1485958d0e36d0ae758b1e33c01ba99107eb54baa539cc7db233a330",
457
- "vout": 0,
458
- "scriptSig": {
459
- "asm": "00142d62a39a40a30228c77de441c1f0993fe1707dda",
460
- "hex": "1600142d62a39a40a30228c77de441c1f0993fe1707dda"
461
- },
462
- "txinwitness": [
463
- "3045022100d4a981592a3e314ee20c662b7a34339d26855c0ecff1588154f0f41856a17a990220444364570c93d5a7a82de8d863dc51868e69ff357901926eedd43c305e51818701",
464
- "03efc6b990c1626d08bd176aab0e545a4f55c627c7ddee878d12bbbc46a126177a"
465
- ],
466
- "sequence": 4294967295
467
- }
468
- ],
469
- "vout": [
470
- {
471
- "value": 98.74662473,
472
- "n": 0,
473
- "scriptPubKey": {
474
- "asm": "OP_HASH160 5a102ac5376429003168cad88c80331daa3a7471 OP_EQUAL",
475
- "hex": "a9145a102ac5376429003168cad88c80331daa3a747187",
476
- "reqSigs": 1,
477
- "type": "scripthash",
478
- "addresses": [
479
- "2N1TSArdd2pt9RoqE3LXY55ixpRE9e5aot8"
480
- ]
481
- }
482
- },
483
- {
484
- "value": 0.00010000,
485
- "n": 1,
486
- "scriptPubKey": {
487
- "asm": "OP_HASH160 e5776c571979173607c28d5c1882465014b777dc OP_EQUAL",
488
- "hex": "a914e5776c571979173607c28d5c1882465014b777dc87",
489
- "reqSigs": 1,
490
- "type": "scripthash",
491
- "addresses": [
492
- "2NEAXntA12Zoa7NdsNyC9ncw7HLKH66jKNH"
493
- ]
494
- }
495
- }
496
- ],
497
- "hex": "0200000000010130a333b27dcc39a5ba54eb0791a91bc0331e8b75aed0360e8d9585144fc2425700000000171600142d62a39a40a30228c77de441c1f0993fe1707ddaffffffff024964934c0200000017a9145a102ac5376429003168cad88c80331daa3a747187102700000000000017a914e5776c571979173607c28d5c1882465014b777dc8702483045022100d4a981592a3e314ee20c662b7a34339d26855c0ecff1588154f0f41856a17a990220444364570c93d5a7a82de8d863dc51868e69ff357901926eedd43c305e518187012103efc6b990c1626d08bd176aab0e545a4f55c627c7ddee878d12bbbc46a126177a00000000",
498
- "blockhash": "00000000c117e8cb6cb65ef6afc22dda3ab906dc6a42669a154fea124ecec3ca",
499
- "confirmations": 3,
500
- "time": 1633609698,
501
- "blocktime": 1633609698
502
- };
503
-
504
- const p2pkh: CoreTx = {
505
- "txid": "03717ce615625148a3a3aad38a68fa2aa68e54633259cb98a7a16c16c33a71c3",
506
- "hash": "03717ce615625148a3a3aad38a68fa2aa68e54633259cb98a7a16c16c33a71c3",
507
- "version": 2,
508
- "size": 254,
509
- "vsize": 254,
510
- "weight": 1016,
511
- "locktime": 0,
512
- "vin": [
513
- {
514
- "txid": "80453b180c6616431d28d395a6a89cb331d7ecb21bf3ac1cbb68c90dba6e95ff",
515
- "vout": 1,
516
- "scriptSig": {
517
- "asm": "304402205c809d58dadb3dbe1b9cf129549036b00f7dfa876f7f6c1686d8df77b69cef2c02206512480ee394c3298c8b66340c0ccddddc3c245b4e870a31bf52c9eec9ad69b6[ALL] 037ed58c914720772c59f7a1e7e76fba0ef95d7c5667119798586301519b9ad2cf",
518
- "hex": "47304402205c809d58dadb3dbe1b9cf129549036b00f7dfa876f7f6c1686d8df77b69cef2c02206512480ee394c3298c8b66340c0ccddddc3c245b4e870a31bf52c9eec9ad69b60121037ed58c914720772c59f7a1e7e76fba0ef95d7c5667119798586301519b9ad2cf"
519
- },
520
- "sequence": 4294967295
521
- }
522
- ],
523
- "vout": [
524
- {
525
- "value": 0.00000000,
526
- "n": 0,
527
- "scriptPubKey": {
528
- "asm": "OP_RETURN 696f6e3a322e516d59386b56553674567364344a65764d64656d5a744143635152647675776b546158344d455a4e336778677072",
529
- "hex": "6a34696f6e3a322e516d59386b56553674567364344a65764d64656d5a744143635152647675776b546158344d455a4e336778677072",
530
- "type": "nulldata"
531
- }
532
- },
533
- {
534
- "value": 1.33032112,
535
- "n": 1,
536
- "scriptPubKey": {
537
- "asm": "OP_DUP OP_HASH160 7628046f6ec479c031d03a47b6a003c4dedb1cad OP_EQUALVERIFY OP_CHECKSIG",
538
- "hex": "76a9147628046f6ec479c031d03a47b6a003c4dedb1cad88ac",
539
- "reqSigs": 1,
540
- "type": "pubkeyhash",
541
- "addresses": [
542
- "mrHhy9DgpBbDLoJsACv4QXXY7f2B5Fq5o1"
543
- ]
544
- }
545
- }
546
- ],
547
- "hex": "0200000001ff956eba0dc968bb1cacf31bb2ecd731b39ca8a695d3281d4316660c183b4580010000006a47304402205c809d58dadb3dbe1b9cf129549036b00f7dfa876f7f6c1686d8df77b69cef2c02206512480ee394c3298c8b66340c0ccddddc3c245b4e870a31bf52c9eec9ad69b60121037ed58c914720772c59f7a1e7e76fba0ef95d7c5667119798586301519b9ad2cfffffffff020000000000000000366a34696f6e3a322e516d59386b56553674567364344a65764d64656d5a744143635152647675776b546158344d455a4e336778677072b0e8ed07000000001976a9147628046f6ec479c031d03a47b6a003c4dedb1cad88ac00000000",
548
- "blockhash": "0000000000000040f9117341ca31f40e4f440fc6f6552a3b3f15e96ed9edeb3e",
549
- "confirmations": 1,
550
- "time": 1633611385,
551
- "blocktime": 1633611385
552
- };
553
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
554
- const p2wpkhTwoInputs = {
555
- "txid": "1913b7b5ffdcb5f32b9aca1f5eec2a189e7c66650f82b560eae211265fc995b7",
556
- "hash": "c3439dcd3489373c586c7aed48c32f2b5d9c71aad24acd765a61684d98690a3f",
557
- "version": 2,
558
- "size": 388,
559
- "vsize": 226,
560
- "weight": 904,
561
- "locktime": 0,
562
- "vin": [
563
- {
564
- "txid": "5512d5788d4c26117f093de91223ef384c3fb22799810a92e3304bb6f0819224",
565
- "vout": 1,
566
- "scriptSig": {
567
- "asm": "0014c1ac0d63d0258ea1b6fe90ef72d0c35d8d773dd3",
568
- "hex": "160014c1ac0d63d0258ea1b6fe90ef72d0c35d8d773dd3"
569
- },
570
- "txinwitness": [
571
- "30440220543617c5f4504dc29d34d2d06d0d7733dac4ec418b77c67feefb29f3f82ba3d80220690b784c52c3375f4ba9e64cc5c0aeb6a1b9fc6aadda0062905c06ce3bbba57501",
572
- "02fb255ed920db5c2f507289202eb60a160e5a067ee7e30199a4ed81b74c22e441"
573
- ],
574
- "sequence": 4294967295
575
- },
576
- {
577
- "txid": "28ad5054e029252d72da37f13fce66212d7f7763845b4a8c4aaf78e897b2bf9f",
578
- "vout": 1,
579
- "scriptSig": {
580
- "asm": "0014c1ac0d63d0258ea1b6fe90ef72d0c35d8d773dd3",
581
- "hex": "160014c1ac0d63d0258ea1b6fe90ef72d0c35d8d773dd3"
582
- },
583
- "txinwitness": [
584
- "3044022049e7f3015a33ccdb015fe3891667564fd37111272df57e58447645c7bad8fed0022074d1e93ba946453896d0f0bc500df3a1e0d5bb5ad10cd9906736d5fbaebadd5801",
585
- "02fb255ed920db5c2f507289202eb60a160e5a067ee7e30199a4ed81b74c22e441"
586
- ],
587
- "sequence": 4294967295
588
- }
589
- ],
590
- "vout": [
591
- {
592
- "value": 0.01800000,
593
- "n": 0,
594
- "scriptPubKey": {
595
- "asm": "OP_DUP OP_HASH160 f73384bcc3951ab6a75541ff79a9a51f82056ed8 OP_EQUALVERIFY OP_CHECKSIG",
596
- "hex": "76a914f73384bcc3951ab6a75541ff79a9a51f82056ed888ac",
597
- "address": "n442v1DrXQNim9gjjctKjyGVoe717hNdtG",
598
- "type": "pubkeyhash"
599
- }
600
- }
601
- ],
602
- "hex": "02000000000102249281f0b64b30e3920a819927b23f4c38ef2312e93d097f11264c8d78d512550100000017160014c1ac0d63d0258ea1b6fe90ef72d0c35d8d773dd3ffffffff9fbfb297e878af4a8c4a5b8463777f2d2166ce3ff137da722d2529e05450ad280100000017160014c1ac0d63d0258ea1b6fe90ef72d0c35d8d773dd3ffffffff0140771b00000000001976a914f73384bcc3951ab6a75541ff79a9a51f82056ed888ac024730440220543617c5f4504dc29d34d2d06d0d7733dac4ec418b77c67feefb29f3f82ba3d80220690b784c52c3375f4ba9e64cc5c0aeb6a1b9fc6aadda0062905c06ce3bbba575012102fb255ed920db5c2f507289202eb60a160e5a067ee7e30199a4ed81b74c22e44102473044022049e7f3015a33ccdb015fe3891667564fd37111272df57e58447645c7bad8fed0022074d1e93ba946453896d0f0bc500df3a1e0d5bb5ad10cd9906736d5fbaebadd58012102fb255ed920db5c2f507289202eb60a160e5a067ee7e30199a4ed81b74c22e44100000000",
603
- "blockhash": "00000000025a711e6cd4bce9138dc852232a4494afbf36d8bb80499a786da2a4",
604
- "confirmations": 1,
605
- "time": 1633944124,
606
- "blocktime": 1633944124
607
- };
608
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
609
- const wrappedP2wpkhTwoInputs = {
610
- "txid": "c03119b538c78f56c8ce2e6cc5fc6998d447eeef42e34c12692764a3f1a3da7c",
611
- "hash": "6b3812304554a6964e43a6971ac533046f4be101e39609f72179856916e20268",
612
- "version": 2,
613
- "size": 420,
614
- "vsize": 257,
615
- "weight": 1026,
616
- "locktime": 0,
617
- "vin": [
618
- {
619
- "txid": "9075ef8fd97f92ff0db344322873f12c42b29661c3960801e05114ba8adcabd6",
620
- "vout": 0,
621
- "scriptSig": {
622
- "asm": "0014e4a7ff7c7e16cb6f15914938e2b92e2801220250",
623
- "hex": "160014e4a7ff7c7e16cb6f15914938e2b92e2801220250"
624
- },
625
- "txinwitness": [
626
- "30450221008a777087167aaeda51cf3532da368a7541630cd7274068ae4353aa1e9e32d7850220628ad0f414ae4cfb7a6dcd590b0e21e003b2ff638c5fc9aaad9b411783b03e3301",
627
- "02de057221383ed65635568e38d4305d9120a4e68e205734a5f95a8feea3dd5f53"
628
- ],
629
- "sequence": 4294967293
630
- },
631
- {
632
- "txid": "d36d3ba59981dab0dad0e02dafa9fa97ad51f4e5a47ffad3ad8544bdb251b70f",
633
- "vout": 0,
634
- "scriptSig": {
635
- "asm": "001442721355859d8f2a461a5badfb19e59a61935692",
636
- "hex": "16001442721355859d8f2a461a5badfb19e59a61935692"
637
- },
638
- "txinwitness": [
639
- "3045022100e49eac220605239d702261c5929e4544e2d3ea70f3372527cee7f6cb31dabd24022015b67591a07e15a7a35ac5cc775e2abbc7fdf41983ad14438961e76029aee52c01",
640
- "02783edf31f3a8845c6350d17a254a73561c02f1d00c69a8972fd91472c1920105"
641
- ],
642
- "sequence": 4294967293
643
- }
644
- ],
645
- "vout": [
646
- {
647
- "value": 0.03532507,
648
- "n": 0,
649
- "scriptPubKey": {
650
- "asm": "OP_HASH160 deb26fa74cb3bb95cd00213172397ec91c5fc9ba OP_EQUAL",
651
- "hex": "a914deb26fa74cb3bb95cd00213172397ec91c5fc9ba87",
652
- "address": "2NDYjkqA8jUpMAqU2rBaSumb5bqa41Ri5BM",
653
- "type": "scripthash"
654
- }
655
- },
656
- {
657
- "value": 0.00069944,
658
- "n": 1,
659
- "scriptPubKey": {
660
- "asm": "OP_HASH160 c0a4669d0b6fd3ce7b22e158ac160f2e656f2592 OP_EQUAL",
661
- "hex": "a914c0a4669d0b6fd3ce7b22e158ac160f2e656f259287",
662
- "address": "2NAopftKM5sNgM7AueL7Cin9NsFv8ykBkUA",
663
- "type": "scripthash"
664
- }
665
- }
666
- ],
667
- "hex": "02000000000102d6abdc8aba1451e0010896c36196b2422cf173283244b30dff927fd98fef75900000000017160014e4a7ff7c7e16cb6f15914938e2b92e2801220250fdffffff0fb751b2bd4485add3fa7fa4e5f451ad97faa9af2de0d0dab0da8199a53b6dd3000000001716001442721355859d8f2a461a5badfb19e59a61935692fdffffff02dbe635000000000017a914deb26fa74cb3bb95cd00213172397ec91c5fc9ba87381101000000000017a914c0a4669d0b6fd3ce7b22e158ac160f2e656f259287024830450221008a777087167aaeda51cf3532da368a7541630cd7274068ae4353aa1e9e32d7850220628ad0f414ae4cfb7a6dcd590b0e21e003b2ff638c5fc9aaad9b411783b03e33012102de057221383ed65635568e38d4305d9120a4e68e205734a5f95a8feea3dd5f5302483045022100e49eac220605239d702261c5929e4544e2d3ea70f3372527cee7f6cb31dabd24022015b67591a07e15a7a35ac5cc775e2abbc7fdf41983ad14438961e76029aee52c012102783edf31f3a8845c6350d17a254a73561c02f1d00c69a8972fd91472c192010500000000",
668
- "blockhash": "00000000025a711e6cd4bce9138dc852232a4494afbf36d8bb80499a786da2a4",
669
- "confirmations": 1,
670
- "time": 1633944124,
671
- "blocktime": 1633944124
672
- };