turing-wallet-provider 1.4.1 → 1.4.3

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 (2) hide show
  1. package/README.md +70 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -164,6 +164,74 @@ for (let i = 0; i < utxosB.length; i++) {
164
164
  broadcastTXsraw(txs.map((tx) => ({ txraw: tx.uncheckedSerialize() })));
165
165
  ```
166
166
 
167
+ ## signAssociatedTransaction
168
+
169
+ ```ts
170
+ //使用示例
171
+ interface intput {
172
+ txId?: string;
173
+ script?: string;
174
+ satoshis?: number;
175
+ outputIndex: number;
176
+ unfinished_script_sig: string;
177
+ sig_position: number;
178
+ }
179
+
180
+ interface output {
181
+ script: string;
182
+ satoshis: number;
183
+ }
184
+
185
+ interface SignAssociatedTransactionRequestData {
186
+ mode: 'sequential' | 'fromSource';//sequential:连续父子交易,fromSource:使用源头交易的所有输出 默认为sequential
187
+ sourceTxraw: string;
188
+ sourceUtxos: intput[];
189
+ inputs: intput[][];
190
+ outputs: output[][];
191
+ autoChange: boolean;//默认为true true则子交易最后一个输出由钱包设置为找零输出
192
+ }
193
+
194
+ //p2pkh示例参数
195
+ const sourceUtxos: intput[] = [
196
+ {
197
+ txId: "",
198
+ outputIndex: 0,
199
+ satoshis: 1000000000,
200
+ script: tbc.Script.buildPublicKeyHashOut(address).toString(),
201
+ unfinished_script_sig: `${publicKey}`,
202
+ sig_position: 0
203
+ }
204
+ ]
205
+
206
+ const inputs: intput[][] = [
207
+ [
208
+ { outputIndex: 0, unfinished_script_sig: `${publicKey}`, sig_position: 0 },
209
+ { outputIndex: 1, unfinished_script_sig: `${publicKey}`, sig_position: 0 },
210
+ {
211
+ txId: "",
212
+ outputIndex: 1,
213
+ satoshis: 1000000000,
214
+ script: tbc.Script.buildPublicKeyHashOut(address).toString(),
215
+ unfinished_script_sig: `${publicKey}`,
216
+ sig_position: 0
217
+ }//和父子交易无关的输入
218
+ ],
219
+ [
220
+ { outputIndex: 0, unfinished_script_sig: `${publicKey}`, sig_position: 0 },
221
+ { outputIndex: 1, unfinished_script_sig: `${publicKey}`, sig_position: 0 }
222
+ ]
223
+ ];
224
+
225
+ const outputs: output[][] = [
226
+ [{ script: tbc.Script.buildPublicKeyHashOut(address).toString(), satoshis: 50000000 }, { script: tbc.Script.buildPublicKeyHashOut(address).toString(), satoshis: 50000000 }]
227
+
228
+ , [{ script: tbc.Script.buildPublicKeyHashOut(address).toString(), satoshis: 5000000 }, { script: tbc.Script.buildPublicKeyHashOut(address).toString(), satoshis: 5000000 }]
229
+ ]
230
+
231
+ const wallet = useTuringWallet();
232
+ const { txraws } = await wallet.signAssociatedTransaction(params);
233
+ ```
234
+
167
235
  ## sendTransaction
168
236
 
169
237
  ```ts
@@ -297,6 +365,7 @@ const params = [
297
365
  },
298
366
  ];
299
367
  const { txid } = await wallet.sendTransaction(params);
368
+ //const { error } = await wallet.sendTransaction(params);构建或广播交易时出现错误
300
369
  ```
301
370
 
302
371
  ### FT_TRANSFER
@@ -338,6 +407,7 @@ const params = [
338
407
  },
339
408
  ];
340
409
  const { txid } = await wallet.sendTransaction(params);
410
+ //const { error } = await wallet.sendTransaction(params);构建或广播交易时出现错误
341
411
  ```
342
412
 
343
413
  ### POOLNFT_INIT
@@ -469,7 +539,6 @@ const params = [
469
539
  },
470
540
  ];
471
541
  const { txid } = await wallet.sendTransaction(params);
472
- //const { txraw } = await wallet.sendTransaction(params);broadcastEnabled为false
473
542
  //const { error } = await wallet.sendTransaction(params);构建或广播交易时出现错误
474
543
  ```
475
544
 
@@ -486,6 +555,5 @@ const params = [
486
555
  },
487
556
  ];
488
557
  const { txid } = await wallet.sendTransaction(params);
489
- //const { txraw } = await wallet.sendTransaction(params);broadcastEnabled为false
490
558
  //const { error } = await wallet.sendTransaction(params);构建或广播交易时出现错误
491
559
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turing-wallet-provider",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [