@@ -385,13 +385,15 @@ Tx.OUTPUT_SIZE // 34
385
385
``` text
386
386
Tx.create({ getPrivateKey, getPublicKey, sign, toPublicKey });
387
387
tx.hashAndSignAll(txInfo);
388
+ tx.hashAndSignInput(privBytes, txInfo, i, sigHashType);
388
389
tx.legacy.draftSingleOutput({ utxos, inputs, output });
389
390
tx.legacy.finalizePresorted(txDraft, keys);
390
391
391
392
Tx.createDonationOutput();
392
393
393
394
Tx.appraise({ inputs, outputs });
394
- Tx.getId(txHex);
395
+
396
+ Tx.parseUnknown(serializedHex);
395
397
396
398
// Byte-level helpers
397
399
Tx.utils.toVarInt(n);
@@ -402,10 +404,28 @@ Tx.utils.hexToBytes(hex);
402
404
Tx.utils.strToHex(str);
403
405
404
406
// Low-level helpers
405
- Tx.createRaw(txInfoMinimal);
406
- Tx.createHashable(txInfo, inputIndex);
407
+ Tx.SIGHASH_ALL // 0x01
408
+ Tx.SIGHASH_NONE // 0x02
409
+ Tx.SIGHASH_ANYONECANPAY // 0x80
410
+
411
+ Tx.createRaw(txRequestInfo);
412
+ Tx.createForSig(txInfo, inputIndex, sigHashType);
407
413
Tx.createSigned(txInfoSigned);
408
- Tx.hashPartial(txHex, Tx.SIGHASH_ALL);
414
+
415
+ Tx.serialize(txRequestOrTxSigned);
416
+ Tx.serializeForSig(txInfo, sigHashType);
417
+
418
+ Tx.createInputRaw(input, i);
419
+ Tx.createInputForSig(input, i);
420
+
421
+ Tx.serializeInputs(inputs);
422
+ Tx.serializeOutputs(outputs, opts);
423
+
424
+ Tx.serializeInput(input, i);
425
+ Tx.serializeOutput(output, i);
426
+
427
+ Tx.sum(coins);
428
+ Tx.doubleSha256(txBytes) {
409
429
410
430
// Deprecated
411
431
Tx.createLegacyTx(coins, outputs, changeOutput);
@@ -415,7 +435,7 @@ Tx.createLegacyTx(coins, outputs, changeOutput);
415
435
/**
416
436
* Creates a tx signer instance.
417
437
*/
418
- Tx .create ({ getPrivateKey, getPublicKey, sign, toPublicKey } );
438
+ Tx .create (keyUtils );
419
439
420
440
/**
421
441
* Estimates the min, mid, and max sizes of (fees for) a transaction (including memos).
@@ -488,32 +508,47 @@ Tx.createLegacyTx(coins, outputs, changeOutput);
488
508
}
489
509
490
510
/**
491
- * Creates an "null" transaction with minimal information.
492
- * It which CANNOT be used for hashing or signing... and
493
- * we're not sure what it is useful for. Seemingly nothing.
511
+ * Creates a transaction request object with minimal information.
512
+ * It CANNOT be used for hashing or signing. Useful for sharing
513
+ * between wallets as a request to create a shared transaction.
514
+ * (i.e. for CoinJoin)
494
515
*
495
516
* Note: although these basically encode enough information
496
517
* for a payment request, there are better ways to do that.
497
518
*/
498
519
Tx .createRaw (txInfoMinimal);
499
520
500
521
/**
501
- * Creates a transaction with all inputs "null"ed out,
502
- * except for the one corresponding to the given input index.
522
+ * Creates a transaction object with all inputs omitted
523
+ * (SIGHASH_ANYONECANPAY), or "null"ed out, except for the one
524
+ * corresponding to the given input index. That index will
525
+ * contain the lockscript from its previous output.
503
526
*
504
527
* This creates a one-off copy of the transaction suitable for
505
528
* hashing to create the signature that will be inserted into
506
529
* the (unrelated) final transaction.
507
530
*/
508
- Tx .createHashable (txInfo, inputIndex);
531
+ Tx .createForSig (txInfo, inputIndex);
509
532
510
533
/**
511
534
* Creates a transaction that is ready to broadcast to the
512
- * network. It contains signatures from the one-off emphemeral,
513
- * hashable transactions created for each input .
535
+ * network. Each input contains signatures from the one-off
536
+ * emphemeral, ready-to-sign transactions described above .
514
537
*/
515
538
Tx .createSigned (txInfoSigned);
516
539
540
+ /**
541
+ * Creates a transaction hex either for a raw request, or
542
+ * that is signed and ready to broadcast to the network.
543
+ */
544
+ Tx .serialize (txInfo);
545
+
546
+ /**
547
+ * Serialized a transaction as hex, appending the sigHashType
548
+ * of the target input, which is required for signing.
549
+ */
550
+ Tx .serializeForSig (txInfo, sigHashType);
551
+
517
552
/**
518
553
* Double sha256 hashes the signed, broadcastable transaction
519
554
* and reverses the byte order of the reseult.
@@ -526,7 +561,14 @@ Tx.getId(txHex);
526
561
* order because we use a standard ECSDA signing function that
527
562
* expects bytes in the normal order.
528
563
*/
529
- Tx .hashPartial (txHex, Tx .SIGHASH_ALL );
564
+ Tx .doubleSha256 (txBytes);
565
+
566
+ /**
567
+ * Parse a transaction hex, which may be a raw request will "null"-ed
568
+ * inputs, a ready-to-sign transaction with lockscript inputs, or a
569
+ * ready-to-broadcast transaction with signed inputs.
570
+ */
571
+ Tx .parseUnknown (serializedHex);
530
572
```
531
573
532
574
### Utility Functions
0 commit comments