@scure/btc-signer 1.7.0 → 1.8.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.
- package/README.md +52 -1
- package/esm/_type_test.js +1 -1
- package/esm/index.d.ts +12 -12
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +10 -10
- package/esm/index.js.map +1 -1
- package/esm/musig2.js +1 -1
- package/esm/p2p.d.ts +38 -0
- package/esm/p2p.d.ts.map +1 -0
- package/esm/p2p.js +156 -0
- package/esm/p2p.js.map +1 -0
- package/esm/payment.d.ts +77 -21
- package/esm/payment.d.ts.map +1 -1
- package/esm/payment.js +63 -60
- package/esm/payment.js.map +1 -1
- package/esm/psbt.d.ts +1 -1
- package/esm/psbt.d.ts.map +1 -1
- package/esm/psbt.js +2 -35
- package/esm/psbt.js.map +1 -1
- package/esm/script.js +1 -1
- package/esm/transaction.d.ts +56 -4
- package/esm/transaction.d.ts.map +1 -1
- package/esm/transaction.js +151 -8
- package/esm/transaction.js.map +1 -1
- package/esm/utxo.d.ts +3 -55
- package/esm/utxo.d.ts.map +1 -1
- package/esm/utxo.js +5 -114
- package/esm/utxo.js.map +1 -1
- package/index.d.ts +12 -12
- package/index.d.ts.map +1 -1
- package/index.js +58 -58
- package/index.js.map +1 -1
- package/musig2.d.ts +1 -1
- package/musig2.js +2 -2
- package/p2p.d.ts +38 -0
- package/p2p.d.ts.map +1 -0
- package/p2p.js +158 -0
- package/p2p.js.map +1 -0
- package/package.json +11 -11
- package/payment.d.ts +77 -21
- package/payment.d.ts.map +1 -1
- package/payment.js +81 -78
- package/payment.js.map +1 -1
- package/psbt.d.ts +1 -1
- package/psbt.d.ts.map +1 -1
- package/psbt.js +22 -55
- package/psbt.js.map +1 -1
- package/script.js +3 -3
- package/src/_type_test.ts +1 -1
- package/src/index.ts +12 -12
- package/src/musig2.ts +1 -1
- package/src/p2p.ts +158 -0
- package/src/payment.ts +160 -75
- package/src/psbt.ts +2 -36
- package/src/script.ts +1 -1
- package/src/transaction.ts +156 -12
- package/src/utxo.ts +9 -111
- package/transaction.d.ts +56 -4
- package/transaction.d.ts.map +1 -1
- package/transaction.js +222 -75
- package/transaction.js.map +1 -1
- package/utxo.d.ts +3 -55
- package/utxo.d.ts.map +1 -1
- package/utxo.js +43 -156
- package/utxo.js.map +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Audited & minimal library for creating, signing & decoding Bitcoin transactions.
|
|
|
10
10
|
- 🧪 Schnorr & Taproot BIP340/BIP341: P2TR, P2TR-NS, P2TR-MS
|
|
11
11
|
- 📨 BIP174 PSBT, BIP327 MuSig2
|
|
12
12
|
- 🗳️ Easy ordinals and inscriptions
|
|
13
|
-
- 🪶
|
|
13
|
+
- 🪶 40KB gzipped with all deps
|
|
14
14
|
|
|
15
15
|
Initial development has been funded by [Ryan Shea](https://shea.io).
|
|
16
16
|
Musig2 feature has been funded by [Arklabs](https://arklabs.to).
|
|
@@ -72,6 +72,7 @@ import * as btc from '@scure/btc-signer';
|
|
|
72
72
|
- [BIP174 PSBT multi-sig example](#bip174-psbt-multi-sig-example)
|
|
73
73
|
- [UTXO selection](#utxo-selection)
|
|
74
74
|
- [MuSig2](#musig2)
|
|
75
|
+
- [P2P, ElligatorSwift, BIP324](#p2p-elligatorswift-bip324)
|
|
75
76
|
- [Ordinals and custom scripts](#ordinals-and-custom-scripts)
|
|
76
77
|
- [Utils](#utils)
|
|
77
78
|
- [getAddress](#getaddress)
|
|
@@ -964,6 +965,47 @@ We've developed separate [micro-ordinals](https://github.com/paulmillr/micro-ord
|
|
|
964
965
|
- CLI tool that allows to upload files as inscriptions
|
|
965
966
|
- Example usage of custom scripts
|
|
966
967
|
|
|
968
|
+
## P2P, ElligatorSwift, BIP324
|
|
969
|
+
|
|
970
|
+
Experimental implementation of ElligatorSwift from [BIP324](https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki)
|
|
971
|
+
is available.
|
|
972
|
+
|
|
973
|
+
ElligatorSwift is Schnorr-like x-only ECDH with public keys indistinguishable from uniformly random bytes.
|
|
974
|
+
|
|
975
|
+
Check out [libsecp](https://github.com/bitcoin/bitcoin/blob/master/src/secp256k1/doc/ellswift.md) docs.
|
|
976
|
+
|
|
977
|
+
```ts
|
|
978
|
+
import { elligatorSwift } from '@scure/btc-signer/p2p';
|
|
979
|
+
|
|
980
|
+
const alice = elligatorSwift.keygen();
|
|
981
|
+
const bob = elligatorSwift.keygen();
|
|
982
|
+
// ECDH
|
|
983
|
+
const sharedAlice = elligatorSwift.getSharedSecret(alice.privateKey, bob.publicKey);
|
|
984
|
+
const sharedBob = elligatorSwift.getSharedSecret(bob.privateKey, alice.publicKey);
|
|
985
|
+
// deepStrictEqual(sharedAlice, sharedBob);
|
|
986
|
+
// ECDH BIP324
|
|
987
|
+
const sharedAlice2 = elligatorSwift.getSharedSecretBip324(
|
|
988
|
+
alice.privateKey,
|
|
989
|
+
bob.publicKey,
|
|
990
|
+
alice.publicKey,
|
|
991
|
+
true
|
|
992
|
+
);
|
|
993
|
+
const sharedBob2 = elligatorSwift.getSharedSecretBip324(
|
|
994
|
+
bob.privateKey,
|
|
995
|
+
alice.publicKey,
|
|
996
|
+
bob.publicKey,
|
|
997
|
+
false
|
|
998
|
+
);
|
|
999
|
+
// deepStrictEqual(sharedAlice2, sharedBob2);
|
|
1000
|
+
// pubKey decoding
|
|
1001
|
+
for (const k of [alice, bob]) {
|
|
1002
|
+
// deepStrictEqual(
|
|
1003
|
+
// toHex(elligatorSwift.decode(k.publicKey)),
|
|
1004
|
+
// toHex(secp256k1.getPublicKey(k.privateKey, true).subarray(1))
|
|
1005
|
+
// );
|
|
1006
|
+
}
|
|
1007
|
+
```
|
|
1008
|
+
|
|
967
1009
|
## Utils
|
|
968
1010
|
|
|
969
1011
|
### secp256k1 keys
|
|
@@ -1136,6 +1178,8 @@ If you see anything unusual: investigate and report.
|
|
|
1136
1178
|
|
|
1137
1179
|
- **Commits** are signed with PGP keys, to prevent forgery. Make sure to verify commit signatures
|
|
1138
1180
|
- **Releases** are transparent and built on GitHub CI. Make sure to verify [provenance](https://docs.npmjs.com/generating-provenance-statements) logs
|
|
1181
|
+
- Use GitHub CLI to verify single-file builds:
|
|
1182
|
+
`gh attestation verify --owner paulmillr scure-btc-signer.js`
|
|
1139
1183
|
- **Rare releasing** is followed to ensure less re-audit need for end-users
|
|
1140
1184
|
- **Dependencies** are minimized and locked-down: any dependency could get hacked and users will be downloading malware with every install.
|
|
1141
1185
|
- We make sure to use as few dependencies as possible
|
|
@@ -1157,6 +1201,13 @@ For this package, there are 4 dependencies; and a few dev dependencies:
|
|
|
1157
1201
|
- `npm run lint` / `npm run format` will run linter / fix linter issues.
|
|
1158
1202
|
- `npm run build:release` will build single file
|
|
1159
1203
|
|
|
1204
|
+
## Learning & documentation
|
|
1205
|
+
|
|
1206
|
+
There are several nice resources on the topic:
|
|
1207
|
+
|
|
1208
|
+
- [Learn me a bitcoin](https://learnmeabitcoin.com)
|
|
1209
|
+
- [Bitcoin wiki](https://bitcoinwiki.org)
|
|
1210
|
+
|
|
1160
1211
|
## License
|
|
1161
1212
|
|
|
1162
1213
|
MIT (c) Paul Miller [(https://paulmillr.com)](https://paulmillr.com), see LICENSE file.
|
package/esm/_type_test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { secp256k1 as secp } from '@noble/curves/secp256k1';
|
|
2
2
|
import { hex } from '@scure/base';
|
|
3
|
-
import * as btc from
|
|
3
|
+
import * as btc from "./index.js";
|
|
4
4
|
const privKey1 = hex.decode('0101010101010101010101010101010101010101010101010101010101010101');
|
|
5
5
|
const P1 = secp.getPublicKey(privKey1, true);
|
|
6
6
|
const wpkh = btc.p2wpkh(P1);
|
package/esm/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*! scure-btc-signer - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2
|
-
import { compareBytes, taprootTweakPubkey } from './utils.
|
|
3
|
-
export { multisig, p2ms, p2pk, p2pkh, p2sh, p2tr, p2tr_ms, p2tr_ns, p2tr_pk, p2wpkh, p2wsh } from './payment.
|
|
4
|
-
export { CompactSize, MAX_SCRIPT_BYTE_LENGTH, OP, RawTx, RawWitness, Script, ScriptNum, } from './script.
|
|
5
|
-
export type { ScriptType } from './script.
|
|
6
|
-
export { Transaction } from './transaction.
|
|
7
|
-
export { NETWORK, TAPROOT_UNSPENDABLE_KEY, TEST_NETWORK } from './utils.
|
|
8
|
-
export {
|
|
2
|
+
import { compareBytes, taprootTweakPubkey } from './utils.ts';
|
|
3
|
+
export { multisig, p2ms, p2pk, p2pkh, p2sh, p2tr, p2tr_ms, p2tr_ns, p2tr_pk, p2wpkh, p2wsh } from './payment.ts';
|
|
4
|
+
export { CompactSize, MAX_SCRIPT_BYTE_LENGTH, OP, RawTx, RawWitness, Script, ScriptNum, } from './script.ts';
|
|
5
|
+
export type { ScriptType } from './script.ts';
|
|
6
|
+
export { getInputType, Transaction } from './transaction.ts';
|
|
7
|
+
export { NETWORK, TAPROOT_UNSPENDABLE_KEY, TEST_NETWORK } from './utils.ts';
|
|
8
|
+
export { selectUTXO } from './utxo.ts';
|
|
9
9
|
export declare const utils: {
|
|
10
10
|
isBytes: (a: unknown) => a is Uint8Array;
|
|
11
11
|
concatBytes: (...arrays: Uint8Array[]) => Uint8Array;
|
|
@@ -14,9 +14,9 @@ export declare const utils: {
|
|
|
14
14
|
randomPrivateKeyBytes: () => Uint8Array;
|
|
15
15
|
taprootTweakPubkey: typeof taprootTweakPubkey;
|
|
16
16
|
};
|
|
17
|
-
export { _sortPubkeys, Address, combinations, getAddress, OutScript, sortedMultisig, taprootListToTree, WIF, } from './payment.
|
|
18
|
-
export type { CustomScript, OptScript } from './payment.
|
|
19
|
-
export { _DebugPSBT, TaprootControlBlock } from './psbt.
|
|
20
|
-
export { bip32Path, Decimal, DEFAULT_SEQUENCE, PSBTCombine, SigHash } from './transaction.
|
|
21
|
-
export { _cmpBig, _Estimator } from './utxo.
|
|
17
|
+
export { _sortPubkeys, Address, combinations, getAddress, OutScript, sortedMultisig, taprootListToTree, WIF, } from './payment.ts';
|
|
18
|
+
export type { CustomScript, OptScript } from './payment.ts';
|
|
19
|
+
export { _DebugPSBT, TaprootControlBlock } from './psbt.ts';
|
|
20
|
+
export { bip32Path, Decimal, DEFAULT_SEQUENCE, PSBTCombine, SigHash } from './transaction.ts';
|
|
21
|
+
export { _cmpBig, _Estimator } from './utxo.ts';
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EACL,YAAY,EAKZ,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,QAAQ,EACR,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EACxE,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,EAAE,EACF,KAAK,EACL,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EACL,YAAY,EAKZ,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,QAAQ,EACR,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EACxE,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,EAAE,EACF,KAAK,EACL,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,eAAO,MAAM,KAAK;;;;;;;CAOjB,CAAC;AAEF,OAAO,EACL,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,UAAU,EACV,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,GAAG,GACJ,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*! scure-btc-signer - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2
|
-
import { compareBytes, concatBytes, isBytes, pubSchnorr, randomPrivateKeyBytes, taprootTweakPubkey, } from
|
|
2
|
+
import { compareBytes, concatBytes, isBytes, pubSchnorr, randomPrivateKeyBytes, taprootTweakPubkey, } from "./utils.js";
|
|
3
3
|
// should multisig be exported as classicMultisig?
|
|
4
4
|
// prettier-ignore
|
|
5
|
-
export { multisig, p2ms, p2pk, p2pkh, p2sh, p2tr, p2tr_ms, p2tr_ns, p2tr_pk, p2wpkh, p2wsh } from
|
|
6
|
-
export { CompactSize, MAX_SCRIPT_BYTE_LENGTH, OP, RawTx, RawWitness, Script, ScriptNum, } from
|
|
7
|
-
export { Transaction } from
|
|
8
|
-
export { NETWORK, TAPROOT_UNSPENDABLE_KEY, TEST_NETWORK } from
|
|
9
|
-
export {
|
|
5
|
+
export { multisig, p2ms, p2pk, p2pkh, p2sh, p2tr, p2tr_ms, p2tr_ns, p2tr_pk, p2wpkh, p2wsh } from "./payment.js";
|
|
6
|
+
export { CompactSize, MAX_SCRIPT_BYTE_LENGTH, OP, RawTx, RawWitness, Script, ScriptNum, } from "./script.js";
|
|
7
|
+
export { getInputType, Transaction } from "./transaction.js";
|
|
8
|
+
export { NETWORK, TAPROOT_UNSPENDABLE_KEY, TEST_NETWORK } from "./utils.js";
|
|
9
|
+
export { selectUTXO } from "./utxo.js";
|
|
10
10
|
export const utils = {
|
|
11
11
|
isBytes,
|
|
12
12
|
concatBytes,
|
|
@@ -15,8 +15,8 @@ export const utils = {
|
|
|
15
15
|
randomPrivateKeyBytes,
|
|
16
16
|
taprootTweakPubkey,
|
|
17
17
|
};
|
|
18
|
-
export { _sortPubkeys, Address, combinations, getAddress, OutScript, sortedMultisig, taprootListToTree, WIF, } from
|
|
19
|
-
export { _DebugPSBT, TaprootControlBlock } from
|
|
20
|
-
export { bip32Path, Decimal, DEFAULT_SEQUENCE, PSBTCombine, SigHash } from
|
|
21
|
-
export { _cmpBig, _Estimator } from
|
|
18
|
+
export { _sortPubkeys, Address, combinations, getAddress, OutScript, sortedMultisig, taprootListToTree, WIF, } from "./payment.js"; // remove
|
|
19
|
+
export { _DebugPSBT, TaprootControlBlock } from "./psbt.js"; // remove
|
|
20
|
+
export { bip32Path, Decimal, DEFAULT_SEQUENCE, PSBTCombine, SigHash } from "./transaction.js"; // remove
|
|
21
|
+
export { _cmpBig, _Estimator } from "./utxo.js";
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EACL,YAAY,EACZ,WAAW,EACX,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,kDAAkD;AAClD,kBAAkB;AAClB,OAAO,EACL,QAAQ,EACR,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EACxE,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,EAAE,EACF,KAAK,EACL,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,EACL,YAAY,EACZ,WAAW,EACX,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,kDAAkD;AAClD,kBAAkB;AAClB,OAAO,EACL,QAAQ,EACR,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EACxE,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,EAAE,EACF,KAAK,EACL,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,OAAO;IACP,WAAW;IACX,YAAY;IACZ,UAAU;IACV,qBAAqB;IACrB,kBAAkB;CACnB,CAAC;AAEF,OAAO,EACL,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,UAAU,EACV,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,GAAG,GACJ,MAAM,cAAc,CAAC,CAAC,SAAS;AAGhC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC,CAAC,SAAS;AACtE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC,CAAC,SAAS;AACxG,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
|
package/esm/musig2.js
CHANGED
|
@@ -4,7 +4,7 @@ import { schnorr, secp256k1 } from '@noble/curves/secp256k1';
|
|
|
4
4
|
import { abytes, anumber } from '@noble/hashes/_assert';
|
|
5
5
|
import { randomBytes } from '@noble/hashes/utils';
|
|
6
6
|
import * as P from 'micro-packed';
|
|
7
|
-
import { compareBytes } from
|
|
7
|
+
import { compareBytes } from "./utils.js";
|
|
8
8
|
/**
|
|
9
9
|
* Represents an error indicating an invalid contribution from a signer.
|
|
10
10
|
* This allows pointing out which participant is malicious and what specifically is wrong.
|
package/esm/p2p.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BTC P2P layer from BIP324.
|
|
3
|
+
*
|
|
4
|
+
* Experimental ElligatorSwift implementation:
|
|
5
|
+
* Schnorr-like x-only ECDH with public keys indistinguishable from uniformly random bytes.
|
|
6
|
+
*
|
|
7
|
+
* Documented in
|
|
8
|
+
* [BIP324](https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki),
|
|
9
|
+
* [libsecp](https://github.com/bitcoin/bitcoin/blob/master/src/secp256k1/doc/ellswift.md).
|
|
10
|
+
*
|
|
11
|
+
* SwiftEC: Shallue-van de Woestijne Indifferentiable Function to Elliptic Curves.
|
|
12
|
+
* Documented in https://eprint.iacr.org/2022/759.pdf.
|
|
13
|
+
*
|
|
14
|
+
* Curve25519 & P-521 are incompatible with SwiftEC. Differences from SwiftEC:
|
|
15
|
+
* * undefined inputs are remapped
|
|
16
|
+
* * y-parity is encoded in u/t values
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
import type { Hex } from '@noble/curves/abstract/utils';
|
|
21
|
+
import { type ProjPointType as PointType } from '@noble/curves/abstract/weierstrass';
|
|
22
|
+
/**
|
|
23
|
+
* Experimental ElligatorSwift implementation:
|
|
24
|
+
* Schnorr-like x-only ECDH with public keys indistinguishable from uniformly random bytes.
|
|
25
|
+
* Documented in BIP324.
|
|
26
|
+
*/
|
|
27
|
+
export declare const elligatorSwift: {
|
|
28
|
+
_inv: (x: bigint, u: bigint, ellCase: number) => bigint | void;
|
|
29
|
+
encode: (x: bigint | PointType<bigint>) => Uint8Array;
|
|
30
|
+
decode: (data: Hex) => Uint8Array;
|
|
31
|
+
keygen: () => {
|
|
32
|
+
privateKey: Uint8Array<ArrayBufferLike>;
|
|
33
|
+
publicKey: Uint8Array<ArrayBufferLike>;
|
|
34
|
+
};
|
|
35
|
+
getSharedSecret: (privateKeyA: Hex, publicKeyB: Hex) => Uint8Array<ArrayBufferLike>;
|
|
36
|
+
getSharedSecretBip324: (privateKeyOurs: Hex, publicKeyTheirs: Hex, publicKeyOurs: Hex, initiating: boolean) => Uint8Array<ArrayBufferLike>;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=p2p.d.ts.map
|
package/esm/p2p.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"p2p.d.ts","sourceRoot":"","sources":["../src/p2p.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AAOxD,OAAO,EAAE,KAAK,aAAa,IAAI,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAsBrF;;;;GAIG;AACH,eAAO,MAAM,cAAc;cAEf,MAAM,KAAK,MAAM,WAAW,MAAM,KAAG,MAAM,GAAG,IAAI;gBA+BhD,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,KAAG,UAAU;mBAmBpC,GAAG,KAAG,UAAU;;;;;mCA8BA,GAAG,cAAc,GAAG;4CASjC,GAAG,mBACF,GAAG,iBACL,GAAG,cACN,OAAO;CAQtB,CAAC"}
|
package/esm/p2p.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BTC P2P layer from BIP324.
|
|
3
|
+
*
|
|
4
|
+
* Experimental ElligatorSwift implementation:
|
|
5
|
+
* Schnorr-like x-only ECDH with public keys indistinguishable from uniformly random bytes.
|
|
6
|
+
*
|
|
7
|
+
* Documented in
|
|
8
|
+
* [BIP324](https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki),
|
|
9
|
+
* [libsecp](https://github.com/bitcoin/bitcoin/blob/master/src/secp256k1/doc/ellswift.md).
|
|
10
|
+
*
|
|
11
|
+
* SwiftEC: Shallue-van de Woestijne Indifferentiable Function to Elliptic Curves.
|
|
12
|
+
* Documented in https://eprint.iacr.org/2022/759.pdf.
|
|
13
|
+
*
|
|
14
|
+
* Curve25519 & P-521 are incompatible with SwiftEC. Differences from SwiftEC:
|
|
15
|
+
* * undefined inputs are remapped
|
|
16
|
+
* * y-parity is encoded in u/t values
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
import { FpIsSquare } from '@noble/curves/abstract/modular';
|
|
21
|
+
import { bytesToNumberBE, concatBytes, ensureBytes, numberToBytesBE, } from '@noble/curves/abstract/utils';
|
|
22
|
+
import {} from '@noble/curves/abstract/weierstrass';
|
|
23
|
+
import { schnorr, secp256k1 } from '@noble/curves/secp256k1';
|
|
24
|
+
import { randomBytes } from '@noble/hashes/utils';
|
|
25
|
+
import { tagSchnorr } from "./utils.js";
|
|
26
|
+
const Fp = secp256k1.CURVE.Fp;
|
|
27
|
+
const Point = secp256k1.ProjectivePoint;
|
|
28
|
+
const _1n = BigInt(1);
|
|
29
|
+
const _2n = BigInt(2);
|
|
30
|
+
const MINUS_3_SQRT = Fp.sqrt(Fp.create(BigInt(-3)));
|
|
31
|
+
const _3n = BigInt(3);
|
|
32
|
+
const _4n = BigInt(4);
|
|
33
|
+
const _7n = BigInt(7);
|
|
34
|
+
const isValidX = (x) => FpIsSquare(Fp, Fp.add(Fp.mul(Fp.mul(x, x), x), _7n));
|
|
35
|
+
const trySqrt = (x) => {
|
|
36
|
+
try {
|
|
37
|
+
return Fp.sqrt(x);
|
|
38
|
+
}
|
|
39
|
+
catch (_e) { }
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Experimental ElligatorSwift implementation:
|
|
43
|
+
* Schnorr-like x-only ECDH with public keys indistinguishable from uniformly random bytes.
|
|
44
|
+
* Documented in BIP324.
|
|
45
|
+
*/
|
|
46
|
+
export const elligatorSwift = {
|
|
47
|
+
// (internal stuff, exported for tests only): decode(u, _inv(x, u)) = x
|
|
48
|
+
_inv: (x, u, ellCase) => {
|
|
49
|
+
if (!Number.isSafeInteger(ellCase) || ellCase < 0 || ellCase > 7)
|
|
50
|
+
throw new Error(`elligatorSwift._inv: wrong case=${ellCase}`);
|
|
51
|
+
let v, s;
|
|
52
|
+
// Most rejections happens in 3 condition (in comments, ~33% each)
|
|
53
|
+
const u2 = Fp.mul(u, u); // u**2
|
|
54
|
+
const u3 = Fp.mul(u2, u); // u**3
|
|
55
|
+
if ((ellCase & 2) === 0) {
|
|
56
|
+
if (isValidX(Fp.sub(Fp.neg(x), u)))
|
|
57
|
+
return; // [1 condition]
|
|
58
|
+
v = x;
|
|
59
|
+
s = Fp.div(Fp.neg(Fp.add(u3, _7n)), Fp.add(Fp.add(u2, Fp.mul(u, v)), Fp.mul(v, v))); // = -(u**3 + 7) / (u**2 + u*v + v**2)
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
s = Fp.sub(x, u); // x - u
|
|
63
|
+
if (Fp.is0(s))
|
|
64
|
+
return;
|
|
65
|
+
const t0 = Fp.add(u3, _7n); // (u**3 + 7)
|
|
66
|
+
const t1 = Fp.mul(Fp.mul(_3n, s), u2); // 3 * s * u**2
|
|
67
|
+
// r = (-s * (4 * (u**3 + 7) + 3 * s * u**2)).sqrt()
|
|
68
|
+
const r = trySqrt(Fp.mul(Fp.neg(s), Fp.add(Fp.mul(_4n, t0), t1)));
|
|
69
|
+
if (r === undefined)
|
|
70
|
+
return; // [2 condition]
|
|
71
|
+
if (ellCase & 1 && Fp.is0(r))
|
|
72
|
+
return;
|
|
73
|
+
v = Fp.div(Fp.add(Fp.neg(u), Fp.div(r, s)), _2n); // v = (-u + r / s) / 2
|
|
74
|
+
}
|
|
75
|
+
const w = trySqrt(s);
|
|
76
|
+
if (w === undefined)
|
|
77
|
+
return; // [3 condition]
|
|
78
|
+
const last = ellCase & 5; // ellCase = 0..8, last = 0,1,4,5
|
|
79
|
+
const t0 = last & 1 ? Fp.add(_1n, MINUS_3_SQRT) : Fp.sub(_1n, MINUS_3_SQRT);
|
|
80
|
+
const w0 = last === 0 || last === 5 ? Fp.neg(w) : w; // -w | w
|
|
81
|
+
// w0 * (u * t0 / 2 + v)
|
|
82
|
+
return Fp.mul(w0, Fp.add(Fp.div(Fp.mul(u, t0), _2n), v));
|
|
83
|
+
},
|
|
84
|
+
// Encode public key (point or x coordinate bigint) into 64-byte pseudorandom encoding
|
|
85
|
+
encode: (x) => {
|
|
86
|
+
if (x instanceof secp256k1.ProjectivePoint)
|
|
87
|
+
x = x.x;
|
|
88
|
+
if (typeof x !== 'bigint') {
|
|
89
|
+
throw new Error('elligatorSwift.encode: wrong public key. Should be Projective point or x coordinate (bigint)');
|
|
90
|
+
}
|
|
91
|
+
// 200k test cycles per keygen: avg=4 max=48
|
|
92
|
+
// seems too much, but same as for reference implementation
|
|
93
|
+
while (true) {
|
|
94
|
+
// random scalar 1..Fp.ORDER
|
|
95
|
+
const u = Fp.create(Fp.fromBytes(secp256k1.utils.randomPrivateKey()));
|
|
96
|
+
const ellCase = randomBytes(1)[0] & 7; // [0..8)
|
|
97
|
+
const t = elligatorSwift._inv(x, u, ellCase);
|
|
98
|
+
if (!t)
|
|
99
|
+
continue;
|
|
100
|
+
return concatBytes(numberToBytesBE(u, 32), numberToBytesBE(t, 32));
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
// Decode elligatorSwift point to xonly
|
|
104
|
+
decode: (data) => {
|
|
105
|
+
const _data = ensureBytes('data', data, 64);
|
|
106
|
+
let u = Fp.create(Fp.fromBytes(_data.subarray(0, 32)));
|
|
107
|
+
let t = Fp.create(Fp.fromBytes(_data.subarray(32, 64)));
|
|
108
|
+
if (Fp.is0(u))
|
|
109
|
+
u = Fp.create(_1n);
|
|
110
|
+
if (Fp.is0(t))
|
|
111
|
+
t = Fp.create(_1n);
|
|
112
|
+
const u3 = Fp.mul(Fp.mul(u, u), u); // u**3
|
|
113
|
+
const u3plus7 = Fp.add(u3, _7n);
|
|
114
|
+
// u**3 + t**2 + 7 == 0 -> t = 2 * t
|
|
115
|
+
if (Fp.is0(Fp.add(u3plus7, Fp.mul(t, t))))
|
|
116
|
+
t = Fp.add(t, t);
|
|
117
|
+
// X = (u**3 + 7 - t**2) / (2 * t)
|
|
118
|
+
const x = Fp.div(Fp.sub(u3plus7, Fp.mul(t, t)), Fp.add(t, t));
|
|
119
|
+
// Y = (X + t) / (MINUS_3_SQRT * u);
|
|
120
|
+
const y = Fp.div(Fp.add(x, t), Fp.mul(MINUS_3_SQRT, u));
|
|
121
|
+
// try different cases
|
|
122
|
+
let res = Fp.add(u, Fp.mul(Fp.mul(y, y), _4n)); // u + 4 * Y ** 2,
|
|
123
|
+
if (isValidX(res))
|
|
124
|
+
return numberToBytesBE(res, 32);
|
|
125
|
+
res = Fp.div(Fp.sub(Fp.div(Fp.neg(x), y), u), _2n); // (-X / Y - u) / 2
|
|
126
|
+
if (isValidX(res))
|
|
127
|
+
return numberToBytesBE(res, 32);
|
|
128
|
+
res = Fp.div(Fp.sub(Fp.div(x, y), u), _2n); // (X / Y - u) / 2
|
|
129
|
+
if (isValidX(res))
|
|
130
|
+
return numberToBytesBE(res, 32);
|
|
131
|
+
throw new Error('elligatorSwift: cannot decode public key');
|
|
132
|
+
},
|
|
133
|
+
// Generate pair (public key, secret key)
|
|
134
|
+
keygen: () => {
|
|
135
|
+
const privateKey = secp256k1.utils.randomPrivateKey();
|
|
136
|
+
const publicKey = elligatorSwift.encode(Point.fromPrivateKey(privateKey));
|
|
137
|
+
return { privateKey, publicKey };
|
|
138
|
+
},
|
|
139
|
+
// Generates shared secret between a pub key and a priv key
|
|
140
|
+
getSharedSecret: (privateKeyA, publicKeyB) => {
|
|
141
|
+
const pub = elligatorSwift.decode(publicKeyB);
|
|
142
|
+
const priv = ensureBytes('privKey', privateKeyA, 32);
|
|
143
|
+
const point = schnorr.utils.lift_x(Fp.fromBytes(pub));
|
|
144
|
+
const d = bytesToNumberBE(priv);
|
|
145
|
+
return numberToBytesBE(point.multiply(d).x, 32);
|
|
146
|
+
},
|
|
147
|
+
// BIP324 shared secret
|
|
148
|
+
getSharedSecretBip324: (privateKeyOurs, publicKeyTheirs, publicKeyOurs, initiating) => {
|
|
149
|
+
const ours = ensureBytes('publicKeyOurs', publicKeyOurs);
|
|
150
|
+
const theirs = ensureBytes('publicKeyTheirs', publicKeyTheirs);
|
|
151
|
+
const ecdhPoint = elligatorSwift.getSharedSecret(privateKeyOurs, theirs);
|
|
152
|
+
const pubs = initiating ? [ours, theirs] : [theirs, ours];
|
|
153
|
+
return tagSchnorr('bip324_ellswift_xonly_ecdh', ...pubs, ecdhPoint);
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=p2p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,CAAC,4BAA4B,EAAE,GAAG,IAAI,EAAE,SAAS,CAAC,CAAC;IACtE,CAAC;CACF,CAAC"}
|
package/esm/payment.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type Coder } from '@scure/base';
|
|
2
2
|
import * as P from 'micro-packed';
|
|
3
|
-
import { type TransactionInput } from './psbt.
|
|
4
|
-
import { type ScriptType } from './script.
|
|
5
|
-
import { type BTC_NETWORK, type Bytes } from './utils.
|
|
3
|
+
import { type TransactionInput } from './psbt.ts';
|
|
4
|
+
import { type ScriptType } from './script.ts';
|
|
5
|
+
import { type BTC_NETWORK, type Bytes } from './utils.ts';
|
|
6
6
|
export type P2Ret = {
|
|
7
7
|
type: string;
|
|
8
8
|
script: Bytes;
|
|
9
9
|
address?: string;
|
|
10
10
|
redeemScript?: Bytes;
|
|
11
11
|
witnessScript?: Bytes;
|
|
12
|
+
hash?: Bytes;
|
|
12
13
|
};
|
|
13
14
|
type OutP2AType = {
|
|
14
15
|
type: 'p2a';
|
|
@@ -70,12 +71,54 @@ export type CustomScript = Coder<OptScript, CustomScriptOut | undefined> & {
|
|
|
70
71
|
export declare const OutScript: P.CoderType<NonNullable<OutP2AType | OutPKType | OutPKHType | OutSHType | OutWSHType | OutWPKHType | OutMSType | OutTRType | OutTRNSType | OutTRMSType | OutUnknownType | undefined>>;
|
|
71
72
|
export type OutScriptType = typeof OutScript;
|
|
72
73
|
export declare function checkScript(script?: Bytes, redeemScript?: Bytes, witnessScript?: Bytes): void;
|
|
73
|
-
|
|
74
|
-
export
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
export declare const
|
|
74
|
+
type Extends<T, U> = T extends U ? T : never;
|
|
75
|
+
export type P2PK = {
|
|
76
|
+
type: 'pk';
|
|
77
|
+
script: Bytes;
|
|
78
|
+
};
|
|
79
|
+
export declare const p2pk: (pubkey: Bytes, _network?: BTC_NETWORK) => Extends<P2PK, P2Ret>;
|
|
80
|
+
export type P2PKH = {
|
|
81
|
+
type: 'pkh';
|
|
82
|
+
script: Bytes;
|
|
83
|
+
address: string;
|
|
84
|
+
hash: Bytes;
|
|
85
|
+
};
|
|
86
|
+
export declare const p2pkh: (publicKey: Bytes, network?: BTC_NETWORK) => Extends<P2PKH, P2Ret>;
|
|
87
|
+
export type P2SHBase = {
|
|
88
|
+
type: 'sh';
|
|
89
|
+
redeemScript: Bytes;
|
|
90
|
+
script: Bytes;
|
|
91
|
+
address: string;
|
|
92
|
+
hash: Bytes;
|
|
93
|
+
};
|
|
94
|
+
export type P2SHWithWitness = P2SHBase & {
|
|
95
|
+
witnessScript: Bytes;
|
|
96
|
+
};
|
|
97
|
+
export type P2SHWithoutWitness = Omit<P2SHBase, 'witnessScript'>;
|
|
98
|
+
export type P2SHReturn<T extends P2Ret> = T extends {
|
|
99
|
+
witnessScript: Bytes;
|
|
100
|
+
} ? P2SHWithWitness : P2SHWithoutWitness;
|
|
101
|
+
export declare const p2sh: <T extends P2Ret>(child: T, network?: BTC_NETWORK) => Extends<P2SHReturn<T>, P2Ret>;
|
|
102
|
+
export type P2WSH = {
|
|
103
|
+
type: 'wsh';
|
|
104
|
+
witnessScript: Bytes;
|
|
105
|
+
script: Bytes;
|
|
106
|
+
address: string;
|
|
107
|
+
hash: Bytes;
|
|
108
|
+
};
|
|
109
|
+
export declare const p2wsh: (child: P2Ret, network?: BTC_NETWORK) => Extends<P2WSH, P2Ret>;
|
|
110
|
+
export type P2WPKH = {
|
|
111
|
+
type: 'wpkh';
|
|
112
|
+
script: Bytes;
|
|
113
|
+
address: string;
|
|
114
|
+
hash: Bytes;
|
|
115
|
+
};
|
|
116
|
+
export declare const p2wpkh: (publicKey: Bytes, network?: BTC_NETWORK) => Extends<P2WPKH, P2Ret>;
|
|
117
|
+
export type P2MS = {
|
|
118
|
+
type: 'ms';
|
|
119
|
+
script: Bytes;
|
|
120
|
+
};
|
|
121
|
+
export declare const p2ms: (m: number, pubkeys: Bytes[], allowSamePubkeys?: boolean) => Extends<P2MS, P2Ret>;
|
|
79
122
|
export type HashedTree = {
|
|
80
123
|
type: 'leaf';
|
|
81
124
|
version?: number;
|
|
@@ -87,18 +130,23 @@ export type HashedTree = {
|
|
|
87
130
|
right: HashedTree;
|
|
88
131
|
hash: Bytes;
|
|
89
132
|
};
|
|
90
|
-
export type
|
|
133
|
+
export type P2TR = {
|
|
134
|
+
type: 'tr';
|
|
135
|
+
script: Bytes;
|
|
136
|
+
address: string;
|
|
91
137
|
tweakedPubkey: Bytes;
|
|
92
138
|
tapInternalKey: Bytes;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
139
|
+
};
|
|
140
|
+
export type P2TR_TREE = P2TR & {
|
|
141
|
+
tapMerkleRoot: Bytes;
|
|
142
|
+
tapLeafScript: TransactionInput['tapLeafScript'];
|
|
143
|
+
leaves: TaprootLeaf[];
|
|
96
144
|
};
|
|
97
145
|
export type TaprootNode = {
|
|
98
146
|
script: Bytes | string;
|
|
99
147
|
leafVersion?: number;
|
|
100
148
|
weight?: number;
|
|
101
|
-
} & Partial<
|
|
149
|
+
} & Partial<P2TR_TREE>;
|
|
102
150
|
export type TaprootScriptTree = TaprootNode | TaprootScriptTree[];
|
|
103
151
|
export type TaprootScriptList = TaprootNode[];
|
|
104
152
|
export declare function taprootListToTree(taprootList: TaprootScriptList): TaprootScriptTree;
|
|
@@ -118,21 +166,29 @@ export type HashedTreeWithPath = TaprootLeaf | {
|
|
|
118
166
|
};
|
|
119
167
|
export declare const TAP_LEAF_VERSION = 192;
|
|
120
168
|
export declare const tapLeafHash: (script: Bytes, version?: number) => Bytes;
|
|
121
|
-
export
|
|
169
|
+
export type P2TRRet<T> = T extends TaprootScriptTree ? P2TR_TREE : P2TR;
|
|
170
|
+
export declare function p2tr(internalPubKey: Bytes | string, tree?: undefined, network?: BTC_NETWORK, allowUnknownOutputs?: boolean, customScripts?: CustomScript[]): Extends<P2TR, P2Ret>;
|
|
171
|
+
export declare function p2tr(internalPubKey: Bytes | string, tree: TaprootScriptTree, network?: BTC_NETWORK, allowUnknownOutputs?: boolean, customScripts?: CustomScript[]): Extends<P2TR_TREE, P2Ret>;
|
|
122
172
|
export declare function combinations<T>(m: number, list: T[]): T[][];
|
|
123
173
|
/**
|
|
124
174
|
* M-of-N multi-leaf wallet via p2tr_ns. If m == n, single script is emitted.
|
|
125
175
|
* Takes O(n^2) if m != n. 99-of-100 is ok, 5-of-100 is not.
|
|
126
176
|
* `2-of-[A,B,C] => [A,B] | [A,C] | [B,C]`
|
|
127
177
|
*/
|
|
128
|
-
export
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
178
|
+
export type P2TR_NS = {
|
|
179
|
+
type: 'tr_ns';
|
|
180
|
+
script: Bytes;
|
|
181
|
+
};
|
|
182
|
+
export declare const p2tr_ns: (m: number, pubkeys: Bytes[], allowSamePubkeys?: boolean) => Extends<P2TR_NS, P2Ret>[];
|
|
183
|
+
export type P2TR_PK = P2TR_NS;
|
|
184
|
+
export declare const p2tr_pk: (pubkey: Bytes) => Extends<P2TR_PK, P2Ret>;
|
|
185
|
+
export type P2TR_MS = {
|
|
186
|
+
type: 'tr_ms';
|
|
187
|
+
script: Bytes;
|
|
133
188
|
};
|
|
189
|
+
export declare function p2tr_ms(m: number, pubkeys: Bytes[], allowSamePubkeys?: boolean): Extends<P2TR_MS, P2Ret>;
|
|
134
190
|
export declare function getAddress(type: 'pkh' | 'wpkh' | 'tr', privKey: Bytes, network?: BTC_NETWORK): string | undefined;
|
|
135
|
-
export declare const _sortPubkeys: (pubkeys: Bytes[]) =>
|
|
191
|
+
export declare const _sortPubkeys: (pubkeys: Bytes[]) => Bytes[];
|
|
136
192
|
export declare function multisig(m: number, pubkeys: Bytes[], sorted?: boolean, witness?: boolean, network?: BTC_NETWORK): P2Ret;
|
|
137
193
|
export declare function sortedMultisig(m: number, pubkeys: Bytes[], witness?: boolean, network?: BTC_NETWORK): P2Ret;
|
|
138
194
|
export declare function WIF(network?: BTC_NETWORK): Coder<Bytes, string>;
|
package/esm/payment.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,KAAK,EAA0B,MAAM,aAAa,CAAC;AAClF,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAmB,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,KAAK,EAAW,MAAM,YAAY,CAAC;AAOnE,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,KAAK,EAA0B,MAAM,aAAa,CAAC;AAClF,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAmB,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,KAAK,EAAW,MAAM,YAAY,CAAC;AAOnE,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AA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