@opcat-labs/scrypt-ts-opcat 1.0.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/assets/.templates/smart-contract/builtin-libs/TxHashPreimageUtils.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/TxHashPreimageUtils.scrypt.tpl +18 -0
- package/assets/.templates/smart-contract/builtin-libs/TxHashPreimageUtils.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/backtrace.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/backtrace.scrypt.tpl +36 -0
- package/assets/.templates/smart-contract/builtin-libs/backtrace.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/byteStringReader.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/byteStringReader.scrypt.tpl +64 -0
- package/assets/.templates/smart-contract/builtin-libs/byteStringReader.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/byteStringWriter.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/byteStringWriter.scrypt.tpl +48 -0
- package/assets/.templates/smart-contract/builtin-libs/byteStringWriter.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.tpl +101 -0
- package/assets/.templates/smart-contract/builtin-libs/contextUtils.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/p2pk.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/p2pk.scrypt.tpl +7 -0
- package/assets/.templates/smart-contract/builtin-libs/p2pk.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/p2pkh.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/p2pkh.scrypt.tpl +8 -0
- package/assets/.templates/smart-contract/builtin-libs/p2pkh.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/stateLib.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/stateLib.scrypt.tpl +3 -0
- package/assets/.templates/smart-contract/builtin-libs/stateLib.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/stateUtils.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/stateUtils.scrypt.tpl +7 -0
- package/assets/.templates/smart-contract/builtin-libs/stateUtils.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.tpl +89 -0
- package/assets/.templates/smart-contract/builtin-libs/stdUtils.transformer.json +7 -0
- package/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.map +1 -0
- package/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.tpl +42 -0
- package/assets/.templates/smart-contract/builtin-libs/txUtils.transformer.json +7 -0
- package/assets/.templates/smart-contract/types/structs.scrypt.map +1 -0
- package/assets/.templates/smart-contract/types/structs.scrypt.tpl +48 -0
- package/assets/.templates/smart-contract/types/structs.transformer.json +7 -0
- package/assets/smart-contract/builtin-libs/TxHashPreimageUtils.scrypt +20 -0
- package/assets/smart-contract/builtin-libs/backtrace.scrypt +38 -0
- package/assets/smart-contract/builtin-libs/byteStringReader.scrypt +66 -0
- package/assets/smart-contract/builtin-libs/byteStringWriter.scrypt +50 -0
- package/assets/smart-contract/builtin-libs/contextUtils.scrypt +103 -0
- package/assets/smart-contract/builtin-libs/p2pk.scrypt +9 -0
- package/assets/smart-contract/builtin-libs/p2pkh.scrypt +10 -0
- package/assets/smart-contract/builtin-libs/stateLib.scrypt +5 -0
- package/assets/smart-contract/builtin-libs/stateUtils.scrypt +9 -0
- package/assets/smart-contract/builtin-libs/stdUtils.scrypt +91 -0
- package/assets/smart-contract/builtin-libs/txUtils.scrypt +44 -0
- package/assets/smart-contract/types/structs.scrypt +50 -0
- package/dist/cjs/features/call.cjs +38 -0
- package/dist/cjs/features/call.js.map +1 -0
- package/dist/cjs/features/deploy.cjs +33 -0
- package/dist/cjs/features/deploy.js.map +1 -0
- package/dist/cjs/features/index.cjs +8 -0
- package/dist/cjs/features/index.js.map +1 -0
- package/dist/cjs/globalTypes.cjs +3 -0
- package/dist/cjs/globalTypes.js.map +1 -0
- package/dist/cjs/index.cjs +55 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/networks.cjs +69 -0
- package/dist/cjs/networks.js.map +1 -0
- package/dist/cjs/providers/chainProvider.cjs +3 -0
- package/dist/cjs/providers/chainProvider.js.map +1 -0
- package/dist/cjs/providers/dummyProvider.cjs +87 -0
- package/dist/cjs/providers/dummyProvider.js.map +1 -0
- package/dist/cjs/providers/index.cjs +13 -0
- package/dist/cjs/providers/index.js.map +1 -0
- package/dist/cjs/providers/mempoolProvider.cjs +207 -0
- package/dist/cjs/providers/mempoolProvider.js.map +1 -0
- package/dist/cjs/providers/rpcProvider.cjs +296 -0
- package/dist/cjs/providers/rpcProvider.js.map +1 -0
- package/dist/cjs/providers/utxoProvider.cjs +18 -0
- package/dist/cjs/providers/utxoProvider.js.map +1 -0
- package/dist/cjs/psbt/bip66.cjs +182 -0
- package/dist/cjs/psbt/bip66.js.map +1 -0
- package/dist/cjs/psbt/bufferutils.cjs +186 -0
- package/dist/cjs/psbt/bufferutils.js.map +1 -0
- package/dist/cjs/psbt/contextProvider.cjs +111 -0
- package/dist/cjs/psbt/contextProvider.js.map +1 -0
- package/dist/cjs/psbt/extPsbt.cjs +589 -0
- package/dist/cjs/psbt/extPsbt.js.map +1 -0
- package/dist/cjs/psbt/psbt.cjs +973 -0
- package/dist/cjs/psbt/psbt.js.map +1 -0
- package/dist/cjs/psbt/psbtutils.cjs +140 -0
- package/dist/cjs/psbt/psbtutils.js.map +1 -0
- package/dist/cjs/psbt/signatureutils.cjs +230 -0
- package/dist/cjs/psbt/signatureutils.js.map +1 -0
- package/dist/cjs/psbt/types.cjs +3 -0
- package/dist/cjs/psbt/types.js.map +1 -0
- package/dist/cjs/signer.cjs +3 -0
- package/dist/cjs/signer.js.map +1 -0
- package/dist/cjs/signers/defaultSigner.cjs +68 -0
- package/dist/cjs/signers/defaultSigner.js.map +1 -0
- package/dist/cjs/signers/index.cjs +8 -0
- package/dist/cjs/signers/index.js.map +1 -0
- package/dist/cjs/signers/unisatSigner.cjs +38 -0
- package/dist/cjs/signers/unisatSigner.js.map +1 -0
- package/dist/cjs/smart-contract/abi.cjs +380 -0
- package/dist/cjs/smart-contract/abi.js.map +1 -0
- package/dist/cjs/smart-contract/abiutils.cjs +183 -0
- package/dist/cjs/smart-contract/abiutils.js.map +1 -0
- package/dist/cjs/smart-contract/abstractContract.cjs +25 -0
- package/dist/cjs/smart-contract/abstractContract.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/backtrace.cjs +102 -0
- package/dist/cjs/smart-contract/builtin-libs/backtrace.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/byteStringReader.cjs +138 -0
- package/dist/cjs/smart-contract/builtin-libs/byteStringReader.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/byteStringWriter.cjs +109 -0
- package/dist/cjs/smart-contract/builtin-libs/byteStringWriter.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/contextUtils.cjs +304 -0
- package/dist/cjs/smart-contract/builtin-libs/contextUtils.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/index.cjs +18 -0
- package/dist/cjs/smart-contract/builtin-libs/index.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/p2pk.cjs +74 -0
- package/dist/cjs/smart-contract/builtin-libs/p2pk.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/p2pkh.cjs +80 -0
- package/dist/cjs/smart-contract/builtin-libs/p2pkh.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/stateLib.cjs +65 -0
- package/dist/cjs/smart-contract/builtin-libs/stateLib.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/stateUtils.cjs +42 -0
- package/dist/cjs/smart-contract/builtin-libs/stateUtils.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/stdUtils.cjs +192 -0
- package/dist/cjs/smart-contract/builtin-libs/stdUtils.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/txHashPreimageUtils.cjs +56 -0
- package/dist/cjs/smart-contract/builtin-libs/txHashPreimageUtils.js.map +1 -0
- package/dist/cjs/smart-contract/builtin-libs/txUtils.cjs +183 -0
- package/dist/cjs/smart-contract/builtin-libs/txUtils.js.map +1 -0
- package/dist/cjs/smart-contract/consts.cjs +100 -0
- package/dist/cjs/smart-contract/consts.js.map +1 -0
- package/dist/cjs/smart-contract/decorators.cjs +83 -0
- package/dist/cjs/smart-contract/decorators.js.map +1 -0
- package/dist/cjs/smart-contract/fns/assert.cjs +17 -0
- package/dist/cjs/smart-contract/fns/assert.js.map +1 -0
- package/dist/cjs/smart-contract/fns/bitwise.cjs +141 -0
- package/dist/cjs/smart-contract/fns/bitwise.js.map +1 -0
- package/dist/cjs/smart-contract/fns/byteString.cjs +106 -0
- package/dist/cjs/smart-contract/fns/byteString.js.map +1 -0
- package/dist/cjs/smart-contract/fns/equals.cjs +66 -0
- package/dist/cjs/smart-contract/fns/equals.js.map +1 -0
- package/dist/cjs/smart-contract/fns/fill.cjs +19 -0
- package/dist/cjs/smart-contract/fns/fill.js.map +1 -0
- package/dist/cjs/smart-contract/fns/hashes.cjs +81 -0
- package/dist/cjs/smart-contract/fns/hashes.js.map +1 -0
- package/dist/cjs/smart-contract/fns/index.cjs +37 -0
- package/dist/cjs/smart-contract/fns/index.js.map +1 -0
- package/dist/cjs/smart-contract/fns/math.cjs +52 -0
- package/dist/cjs/smart-contract/fns/math.js.map +1 -0
- package/dist/cjs/smart-contract/fns/pubKey2Addr.cjs +17 -0
- package/dist/cjs/smart-contract/fns/pubKey2Addr.js.map +1 -0
- package/dist/cjs/smart-contract/methods/backtraceToGenensis.cjs +41 -0
- package/dist/cjs/smart-contract/methods/backtraceToGenensis.js.map +1 -0
- package/dist/cjs/smart-contract/methods/buildOutput.cjs +41 -0
- package/dist/cjs/smart-contract/methods/buildOutput.js.map +1 -0
- package/dist/cjs/smart-contract/methods/checkCtx.cjs +58 -0
- package/dist/cjs/smart-contract/methods/checkCtx.js.map +1 -0
- package/dist/cjs/smart-contract/methods/checkInputState.cjs +16 -0
- package/dist/cjs/smart-contract/methods/checkInputState.js.map +1 -0
- package/dist/cjs/smart-contract/methods/checkInputStateHashes.cjs +16 -0
- package/dist/cjs/smart-contract/methods/checkInputStateHashes.js.map +1 -0
- package/dist/cjs/smart-contract/methods/checkSHPreimage.cjs +17 -0
- package/dist/cjs/smart-contract/methods/checkSHPreimage.js.map +1 -0
- package/dist/cjs/smart-contract/methods/checkSig.cjs +77 -0
- package/dist/cjs/smart-contract/methods/checkSig.js.map +1 -0
- package/dist/cjs/smart-contract/serializer.cjs +145 -0
- package/dist/cjs/smart-contract/serializer.js.map +1 -0
- package/dist/cjs/smart-contract/smartContract.cjs +568 -0
- package/dist/cjs/smart-contract/smartContract.js.map +1 -0
- package/dist/cjs/smart-contract/smartContractLib.cjs +46 -0
- package/dist/cjs/smart-contract/smartContractLib.js.map +1 -0
- package/dist/cjs/smart-contract/stateSerializer.cjs +134 -0
- package/dist/cjs/smart-contract/stateSerializer.js.map +1 -0
- package/dist/cjs/smart-contract/types/abi.cjs +69 -0
- package/dist/cjs/smart-contract/types/abi.js.map +1 -0
- package/dist/cjs/smart-contract/types/artifact.cjs +16 -0
- package/dist/cjs/smart-contract/types/artifact.js.map +1 -0
- package/dist/cjs/smart-contract/types/bn.cjs +117 -0
- package/dist/cjs/smart-contract/types/bn.js.map +1 -0
- package/dist/cjs/smart-contract/types/context.cjs +3 -0
- package/dist/cjs/smart-contract/types/context.js.map +1 -0
- package/dist/cjs/smart-contract/types/index.cjs +16 -0
- package/dist/cjs/smart-contract/types/index.js.map +1 -0
- package/dist/cjs/smart-contract/types/opCode.cjs +754 -0
- package/dist/cjs/smart-contract/types/opCode.js.map +1 -0
- package/dist/cjs/smart-contract/types/primitives.cjs +108 -0
- package/dist/cjs/smart-contract/types/primitives.js.map +1 -0
- package/dist/cjs/smart-contract/types/script.cjs +43 -0
- package/dist/cjs/smart-contract/types/script.js.map +1 -0
- package/dist/cjs/smart-contract/types/structs.cjs +3 -0
- package/dist/cjs/smart-contract/types/structs.js.map +1 -0
- package/dist/cjs/smart-contract/types/utils.cjs +21 -0
- package/dist/cjs/smart-contract/types/utils.js.map +1 -0
- package/dist/cjs/utils/bvm.cjs +30 -0
- package/dist/cjs/utils/bvm.js.map +1 -0
- package/dist/cjs/utils/checkIntegrity.cjs +49 -0
- package/dist/cjs/utils/checkIntegrity.js.map +1 -0
- package/dist/cjs/utils/common.cjs +228 -0
- package/dist/cjs/utils/common.js.map +1 -0
- package/dist/cjs/utils/constants.cjs +5 -0
- package/dist/cjs/utils/constants.js.map +1 -0
- package/dist/cjs/utils/index.cjs +45 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/preimage.cjs +93 -0
- package/dist/cjs/utils/preimage.js.map +1 -0
- package/dist/cjs/utils/proof.cjs +110 -0
- package/dist/cjs/utils/proof.js.map +1 -0
- package/dist/cjs/utils/script_number.cjs +107 -0
- package/dist/cjs/utils/script_number.js.map +1 -0
- package/dist/esm/features/call.js +34 -0
- package/dist/esm/features/call.js.map +1 -0
- package/dist/esm/features/deploy.js +29 -0
- package/dist/esm/features/deploy.js.map +1 -0
- package/dist/esm/features/index.js +3 -0
- package/dist/esm/features/index.js.map +1 -0
- package/dist/esm/globalTypes.js +2 -0
- package/dist/esm/globalTypes.js.map +1 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/networks.js +41 -0
- package/dist/esm/networks.js.map +1 -0
- package/dist/esm/providers/chainProvider.js +2 -0
- package/dist/esm/providers/chainProvider.js.map +1 -0
- package/dist/esm/providers/dummyProvider.js +60 -0
- package/dist/esm/providers/dummyProvider.js.map +1 -0
- package/dist/esm/providers/index.js +5 -0
- package/dist/esm/providers/index.js.map +1 -0
- package/dist/esm/providers/mempoolProvider.js +200 -0
- package/dist/esm/providers/mempoolProvider.js.map +1 -0
- package/dist/esm/providers/rpcProvider.js +266 -0
- package/dist/esm/providers/rpcProvider.js.map +1 -0
- package/dist/esm/providers/utxoProvider.js +13 -0
- package/dist/esm/providers/utxoProvider.js.map +1 -0
- package/dist/esm/psbt/bip66.js +175 -0
- package/dist/esm/psbt/bip66.js.map +1 -0
- package/dist/esm/psbt/bufferutils.js +156 -0
- package/dist/esm/psbt/bufferutils.js.map +1 -0
- package/dist/esm/psbt/contextProvider.js +84 -0
- package/dist/esm/psbt/contextProvider.js.map +1 -0
- package/dist/esm/psbt/extPsbt.js +562 -0
- package/dist/esm/psbt/extPsbt.js.map +1 -0
- package/dist/esm/psbt/psbt.js +945 -0
- package/dist/esm/psbt/psbt.js.map +1 -0
- package/dist/esm/psbt/psbtutils.js +110 -0
- package/dist/esm/psbt/psbtutils.js.map +1 -0
- package/dist/esm/psbt/signatureutils.js +199 -0
- package/dist/esm/psbt/signatureutils.js.map +1 -0
- package/dist/esm/psbt/types.js +2 -0
- package/dist/esm/psbt/types.js.map +1 -0
- package/dist/esm/signer.js +2 -0
- package/dist/esm/signer.js.map +1 -0
- package/dist/esm/signers/defaultSigner.js +63 -0
- package/dist/esm/signers/defaultSigner.js.map +1 -0
- package/dist/esm/signers/index.js +3 -0
- package/dist/esm/signers/index.js.map +1 -0
- package/dist/esm/signers/unisatSigner.js +34 -0
- package/dist/esm/signers/unisatSigner.js.map +1 -0
- package/dist/esm/smart-contract/abi.js +373 -0
- package/dist/esm/smart-contract/abi.js.map +1 -0
- package/dist/esm/smart-contract/abiutils.js +171 -0
- package/dist/esm/smart-contract/abiutils.js.map +1 -0
- package/dist/esm/smart-contract/abstractContract.js +21 -0
- package/dist/esm/smart-contract/abstractContract.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/backtrace.js +98 -0
- package/dist/esm/smart-contract/builtin-libs/backtrace.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/byteStringReader.js +134 -0
- package/dist/esm/smart-contract/builtin-libs/byteStringReader.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/byteStringWriter.js +105 -0
- package/dist/esm/smart-contract/builtin-libs/byteStringWriter.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/contextUtils.js +300 -0
- package/dist/esm/smart-contract/builtin-libs/contextUtils.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/index.js +8 -0
- package/dist/esm/smart-contract/builtin-libs/index.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/p2pk.js +70 -0
- package/dist/esm/smart-contract/builtin-libs/p2pk.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/p2pkh.js +76 -0
- package/dist/esm/smart-contract/builtin-libs/p2pkh.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/stateLib.js +61 -0
- package/dist/esm/smart-contract/builtin-libs/stateLib.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/stateUtils.js +38 -0
- package/dist/esm/smart-contract/builtin-libs/stateUtils.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/stdUtils.js +188 -0
- package/dist/esm/smart-contract/builtin-libs/stdUtils.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/txHashPreimageUtils.js +52 -0
- package/dist/esm/smart-contract/builtin-libs/txHashPreimageUtils.js.map +1 -0
- package/dist/esm/smart-contract/builtin-libs/txUtils.js +179 -0
- package/dist/esm/smart-contract/builtin-libs/txUtils.js.map +1 -0
- package/dist/esm/smart-contract/consts.js +97 -0
- package/dist/esm/smart-contract/consts.js.map +1 -0
- package/dist/esm/smart-contract/decorators.js +78 -0
- package/dist/esm/smart-contract/decorators.js.map +1 -0
- package/dist/esm/smart-contract/fns/assert.js +13 -0
- package/dist/esm/smart-contract/fns/assert.js.map +1 -0
- package/dist/esm/smart-contract/fns/bitwise.js +109 -0
- package/dist/esm/smart-contract/fns/bitwise.js.map +1 -0
- package/dist/esm/smart-contract/fns/byteString.js +97 -0
- package/dist/esm/smart-contract/fns/byteString.js.map +1 -0
- package/dist/esm/smart-contract/fns/equals.js +62 -0
- package/dist/esm/smart-contract/fns/equals.js.map +1 -0
- package/dist/esm/smart-contract/fns/fill.js +15 -0
- package/dist/esm/smart-contract/fns/fill.js.map +1 -0
- package/dist/esm/smart-contract/fns/hashes.js +73 -0
- package/dist/esm/smart-contract/fns/hashes.js.map +1 -0
- package/dist/esm/smart-contract/fns/index.js +9 -0
- package/dist/esm/smart-contract/fns/index.js.map +1 -0
- package/dist/esm/smart-contract/fns/math.js +45 -0
- package/dist/esm/smart-contract/fns/math.js.map +1 -0
- package/dist/esm/smart-contract/fns/pubKey2Addr.js +13 -0
- package/dist/esm/smart-contract/fns/pubKey2Addr.js.map +1 -0
- package/dist/esm/smart-contract/methods/backtraceToGenensis.js +36 -0
- package/dist/esm/smart-contract/methods/backtraceToGenensis.js.map +1 -0
- package/dist/esm/smart-contract/methods/buildOutput.js +36 -0
- package/dist/esm/smart-contract/methods/buildOutput.js.map +1 -0
- package/dist/esm/smart-contract/methods/checkCtx.js +31 -0
- package/dist/esm/smart-contract/methods/checkCtx.js.map +1 -0
- package/dist/esm/smart-contract/methods/checkInputState.js +12 -0
- package/dist/esm/smart-contract/methods/checkInputState.js.map +1 -0
- package/dist/esm/smart-contract/methods/checkInputStateHashes.js +12 -0
- package/dist/esm/smart-contract/methods/checkInputStateHashes.js.map +1 -0
- package/dist/esm/smart-contract/methods/checkSHPreimage.js +13 -0
- package/dist/esm/smart-contract/methods/checkSHPreimage.js.map +1 -0
- package/dist/esm/smart-contract/methods/checkSig.js +73 -0
- package/dist/esm/smart-contract/methods/checkSig.js.map +1 -0
- package/dist/esm/smart-contract/serializer.js +112 -0
- package/dist/esm/smart-contract/serializer.js.map +1 -0
- package/dist/esm/smart-contract/smartContract.js +564 -0
- package/dist/esm/smart-contract/smartContract.js.map +1 -0
- package/dist/esm/smart-contract/smartContractLib.js +42 -0
- package/dist/esm/smart-contract/smartContractLib.js.map +1 -0
- package/dist/esm/smart-contract/stateSerializer.js +129 -0
- package/dist/esm/smart-contract/stateSerializer.js.map +1 -0
- package/dist/esm/smart-contract/types/abi.js +63 -0
- package/dist/esm/smart-contract/types/abi.js.map +1 -0
- package/dist/esm/smart-contract/types/artifact.js +13 -0
- package/dist/esm/smart-contract/types/artifact.js.map +1 -0
- package/dist/esm/smart-contract/types/bn.js +89 -0
- package/dist/esm/smart-contract/types/bn.js.map +1 -0
- package/dist/esm/smart-contract/types/context.js +2 -0
- package/dist/esm/smart-contract/types/context.js.map +1 -0
- package/dist/esm/smart-contract/types/index.js +3 -0
- package/dist/esm/smart-contract/types/index.js.map +1 -0
- package/dist/esm/smart-contract/types/opCode.js +750 -0
- package/dist/esm/smart-contract/types/opCode.js.map +1 -0
- package/dist/esm/smart-contract/types/primitives.js +95 -0
- package/dist/esm/smart-contract/types/primitives.js.map +1 -0
- package/dist/esm/smart-contract/types/script.js +16 -0
- package/dist/esm/smart-contract/types/script.js.map +1 -0
- package/dist/esm/smart-contract/types/structs.js +2 -0
- package/dist/esm/smart-contract/types/structs.js.map +1 -0
- package/dist/esm/smart-contract/types/utils.js +17 -0
- package/dist/esm/smart-contract/types/utils.js.map +1 -0
- package/dist/esm/utils/bvm.js +26 -0
- package/dist/esm/utils/bvm.js.map +1 -0
- package/dist/esm/utils/checkIntegrity.js +41 -0
- package/dist/esm/utils/checkIntegrity.js.map +1 -0
- package/dist/esm/utils/common.js +188 -0
- package/dist/esm/utils/common.js.map +1 -0
- package/dist/esm/utils/constants.js +2 -0
- package/dist/esm/utils/constants.js.map +1 -0
- package/dist/esm/utils/index.js +7 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/preimage.js +65 -0
- package/dist/esm/utils/preimage.js.map +1 -0
- package/dist/esm/utils/proof.js +98 -0
- package/dist/esm/utils/proof.js.map +1 -0
- package/dist/esm/utils/script_number.js +79 -0
- package/dist/esm/utils/script_number.js.map +1 -0
- package/dist/types/features/call.d.ts +21 -0
- package/dist/types/features/call.d.ts.map +1 -0
- package/dist/types/features/deploy.d.ts +16 -0
- package/dist/types/features/deploy.d.ts.map +1 -0
- package/dist/types/features/index.d.ts +3 -0
- package/dist/types/features/index.d.ts.map +1 -0
- package/dist/types/globalTypes.d.ts +37 -0
- package/dist/types/globalTypes.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/networks.d.ts +19 -0
- package/dist/types/networks.d.ts.map +1 -0
- package/dist/types/providers/chainProvider.d.ts +31 -0
- package/dist/types/providers/chainProvider.d.ts.map +1 -0
- package/dist/types/providers/dummyProvider.d.ts +23 -0
- package/dist/types/providers/dummyProvider.d.ts.map +1 -0
- package/dist/types/providers/index.d.ts +6 -0
- package/dist/types/providers/index.d.ts.map +1 -0
- package/dist/types/providers/mempoolProvider.d.ts +28 -0
- package/dist/types/providers/mempoolProvider.d.ts.map +1 -0
- package/dist/types/providers/rpcProvider.d.ts +34 -0
- package/dist/types/providers/rpcProvider.d.ts.map +1 -0
- package/dist/types/providers/utxoProvider.d.ts +43 -0
- package/dist/types/providers/utxoProvider.d.ts.map +1 -0
- package/dist/types/psbt/bip66.d.ts +28 -0
- package/dist/types/psbt/bip66.d.ts.map +1 -0
- package/dist/types/psbt/bufferutils.d.ts +47 -0
- package/dist/types/psbt/bufferutils.d.ts.map +1 -0
- package/dist/types/psbt/contextProvider.d.ts +15 -0
- package/dist/types/psbt/contextProvider.d.ts.map +1 -0
- package/dist/types/psbt/extPsbt.d.ts +131 -0
- package/dist/types/psbt/extPsbt.d.ts.map +1 -0
- package/dist/types/psbt/psbt.d.ts +194 -0
- package/dist/types/psbt/psbt.d.ts.map +1 -0
- package/dist/types/psbt/psbtutils.d.ts +37 -0
- package/dist/types/psbt/psbtutils.d.ts.map +1 -0
- package/dist/types/psbt/signatureutils.d.ts +52 -0
- package/dist/types/psbt/signatureutils.d.ts.map +1 -0
- package/dist/types/psbt/types.d.ts +63 -0
- package/dist/types/psbt/types.d.ts.map +1 -0
- package/dist/types/signer.d.ts +48 -0
- package/dist/types/signer.d.ts.map +1 -0
- package/dist/types/signers/defaultSigner.d.ts +30 -0
- package/dist/types/signers/defaultSigner.d.ts.map +1 -0
- package/dist/types/signers/index.d.ts +4 -0
- package/dist/types/signers/index.d.ts.map +1 -0
- package/dist/types/signers/unisatSigner.d.ts +32 -0
- package/dist/types/signers/unisatSigner.d.ts.map +1 -0
- package/dist/types/smart-contract/abi.d.ts +43 -0
- package/dist/types/smart-contract/abi.d.ts.map +1 -0
- package/dist/types/smart-contract/abiutils.d.ts +51 -0
- package/dist/types/smart-contract/abiutils.d.ts.map +1 -0
- package/dist/types/smart-contract/abstractContract.d.ts +115 -0
- package/dist/types/smart-contract/abstractContract.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/backtrace.d.ts +43 -0
- package/dist/types/smart-contract/builtin-libs/backtrace.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/byteStringReader.d.ts +32 -0
- package/dist/types/smart-contract/builtin-libs/byteStringReader.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/byteStringWriter.d.ts +29 -0
- package/dist/types/smart-contract/builtin-libs/byteStringWriter.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/contextUtils.d.ts +53 -0
- package/dist/types/smart-contract/builtin-libs/contextUtils.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/index.d.ts +8 -0
- package/dist/types/smart-contract/builtin-libs/index.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/p2pk.d.ts +8 -0
- package/dist/types/smart-contract/builtin-libs/p2pk.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/p2pkh.d.ts +8 -0
- package/dist/types/smart-contract/builtin-libs/p2pkh.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/stateLib.d.ts +27 -0
- package/dist/types/smart-contract/builtin-libs/stateLib.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/stateUtils.d.ts +18 -0
- package/dist/types/smart-contract/builtin-libs/stateUtils.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/stdUtils.d.ts +44 -0
- package/dist/types/smart-contract/builtin-libs/stdUtils.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/txHashPreimageUtils.d.ts +8 -0
- package/dist/types/smart-contract/builtin-libs/txHashPreimageUtils.d.ts.map +1 -0
- package/dist/types/smart-contract/builtin-libs/txUtils.d.ts +69 -0
- package/dist/types/smart-contract/builtin-libs/txUtils.d.ts.map +1 -0
- package/dist/types/smart-contract/consts.d.ts +97 -0
- package/dist/types/smart-contract/consts.d.ts.map +1 -0
- package/dist/types/smart-contract/decorators.d.ts +40 -0
- package/dist/types/smart-contract/decorators.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/assert.d.ts +8 -0
- package/dist/types/smart-contract/fns/assert.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/bitwise.d.ts +50 -0
- package/dist/types/smart-contract/fns/bitwise.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/byteString.d.ts +56 -0
- package/dist/types/smart-contract/fns/byteString.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/equals.d.ts +8 -0
- package/dist/types/smart-contract/fns/equals.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/fill.d.ts +11 -0
- package/dist/types/smart-contract/fns/fill.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/hashes.d.ts +60 -0
- package/dist/types/smart-contract/fns/hashes.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/index.d.ts +9 -0
- package/dist/types/smart-contract/fns/index.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/math.d.ts +38 -0
- package/dist/types/smart-contract/fns/math.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/pubKey2Addr.d.ts +11 -0
- package/dist/types/smart-contract/fns/pubKey2Addr.d.ts.map +1 -0
- package/dist/types/smart-contract/methods/backtraceToGenensis.d.ts +20 -0
- package/dist/types/smart-contract/methods/backtraceToGenensis.d.ts.map +1 -0
- package/dist/types/smart-contract/methods/buildOutput.d.ts +25 -0
- package/dist/types/smart-contract/methods/buildOutput.d.ts.map +1 -0
- package/dist/types/smart-contract/methods/checkCtx.d.ts +18 -0
- package/dist/types/smart-contract/methods/checkCtx.d.ts.map +1 -0
- package/dist/types/smart-contract/methods/checkInputState.d.ts +9 -0
- package/dist/types/smart-contract/methods/checkInputState.d.ts.map +1 -0
- package/dist/types/smart-contract/methods/checkInputStateHashes.d.ts +10 -0
- package/dist/types/smart-contract/methods/checkInputStateHashes.d.ts.map +1 -0
- package/dist/types/smart-contract/methods/checkSHPreimage.d.ts +10 -0
- package/dist/types/smart-contract/methods/checkSHPreimage.d.ts.map +1 -0
- package/dist/types/smart-contract/methods/checkSig.d.ts +11 -0
- package/dist/types/smart-contract/methods/checkSig.d.ts.map +1 -0
- package/dist/types/smart-contract/serializer.d.ts +48 -0
- package/dist/types/smart-contract/serializer.d.ts.map +1 -0
- package/dist/types/smart-contract/smartContract.d.ts +274 -0
- package/dist/types/smart-contract/smartContract.d.ts.map +1 -0
- package/dist/types/smart-contract/smartContractLib.d.ts +26 -0
- package/dist/types/smart-contract/smartContractLib.d.ts.map +1 -0
- package/dist/types/smart-contract/stateSerializer.d.ts +8 -0
- package/dist/types/smart-contract/stateSerializer.d.ts.map +1 -0
- package/dist/types/smart-contract/types/abi.d.ts +55 -0
- package/dist/types/smart-contract/types/abi.d.ts.map +1 -0
- package/dist/types/smart-contract/types/artifact.d.ts +108 -0
- package/dist/types/smart-contract/types/artifact.d.ts.map +1 -0
- package/dist/types/smart-contract/types/bn.d.ts +3 -0
- package/dist/types/smart-contract/types/bn.d.ts.map +1 -0
- package/dist/types/smart-contract/types/context.d.ts +126 -0
- package/dist/types/smart-contract/types/context.d.ts.map +1 -0
- package/dist/types/smart-contract/types/index.d.ts +4 -0
- package/dist/types/smart-contract/types/index.d.ts.map +1 -0
- package/dist/types/smart-contract/types/opCode.d.ts +747 -0
- package/dist/types/smart-contract/types/opCode.d.ts.map +1 -0
- package/dist/types/smart-contract/types/primitives.d.ts +217 -0
- package/dist/types/smart-contract/types/primitives.d.ts.map +1 -0
- package/dist/types/smart-contract/types/script.d.ts +14 -0
- package/dist/types/smart-contract/types/script.d.ts.map +1 -0
- package/dist/types/smart-contract/types/structs.d.ts +206 -0
- package/dist/types/smart-contract/types/structs.d.ts.map +1 -0
- package/dist/types/smart-contract/types/utils.d.ts +5 -0
- package/dist/types/smart-contract/types/utils.d.ts.map +1 -0
- package/dist/types/utils/bvm.d.ts +9 -0
- package/dist/types/utils/bvm.d.ts.map +1 -0
- package/dist/types/utils/checkIntegrity.d.ts +46 -0
- package/dist/types/utils/checkIntegrity.d.ts.map +1 -0
- package/dist/types/utils/common.d.ts +61 -0
- package/dist/types/utils/common.d.ts.map +1 -0
- package/dist/types/utils/constants.d.ts +3 -0
- package/dist/types/utils/constants.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/preimage.d.ts +31 -0
- package/dist/types/utils/preimage.d.ts.map +1 -0
- package/dist/types/utils/proof.d.ts +31 -0
- package/dist/types/utils/proof.d.ts.map +1 -0
- package/dist/types/utils/script_number.d.ts +19 -0
- package/dist/types/utils/script_number.d.ts.map +1 -0
- package/package.json +79 -0
- package/scrypt.index.json +85 -0
- package/src/smart-contract/builtin-libs/backtrace.ts +116 -0
- package/src/smart-contract/builtin-libs/byteStringReader.ts +111 -0
- package/src/smart-contract/builtin-libs/byteStringWriter.ts +86 -0
- package/src/smart-contract/builtin-libs/contextUtils.ts +270 -0
- package/src/smart-contract/builtin-libs/index.ts +7 -0
- package/src/smart-contract/builtin-libs/p2pk.ts +58 -0
- package/src/smart-contract/builtin-libs/p2pkh.ts +67 -0
- package/src/smart-contract/builtin-libs/stateLib.ts +82 -0
- package/src/smart-contract/builtin-libs/stateUtils.ts +37 -0
- package/src/smart-contract/builtin-libs/stdUtils.ts +156 -0
- package/src/smart-contract/builtin-libs/txHashPreimageUtils.ts +34 -0
- package/src/smart-contract/builtin-libs/txUtils.ts +152 -0
- package/src/smart-contract/types/structs.ts +244 -0
|
@@ -0,0 +1,973 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isFinalized = exports.Psbt = void 0;
|
|
27
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
28
|
+
const bip174_1 = require("@opcat-labs/bip174");
|
|
29
|
+
const bip174_2 = require("@opcat-labs/bip174");
|
|
30
|
+
const opcat_1 = require("@opcat-labs/opcat");
|
|
31
|
+
const signatureutils = __importStar(require('./signatureutils.cjs'));
|
|
32
|
+
const bufferutils_js_1 = require('./bufferutils.cjs');
|
|
33
|
+
const psbtutils_js_1 = require('./psbtutils.cjs');
|
|
34
|
+
const tools = __importStar(require("uint8array-tools"));
|
|
35
|
+
/**
|
|
36
|
+
* These are the default arguments for a Psbt instance.
|
|
37
|
+
*/
|
|
38
|
+
const DEFAULT_OPTS = {
|
|
39
|
+
/**
|
|
40
|
+
* A bitcoinjs Network object. This is only used if you pass an `address`
|
|
41
|
+
* parameter to addOutput. Otherwise it is not needed and can be left default.
|
|
42
|
+
*/
|
|
43
|
+
network: opcat_1.Networks.testnet,
|
|
44
|
+
/**
|
|
45
|
+
* When extractTransaction is called, the fee rate is checked.
|
|
46
|
+
* THIS IS NOT TO BE RELIED ON.
|
|
47
|
+
* It is only here as a last ditch effort to prevent sending a 500 BTC fee etc.
|
|
48
|
+
*/
|
|
49
|
+
maximumFeeRate: 5000, // satoshi per byte
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Psbt class can parse and generate a PSBT binary based off of the BIP174.
|
|
53
|
+
* There are 6 roles that this class fulfills. (Explained in BIP174)
|
|
54
|
+
*
|
|
55
|
+
* Creator: This can be done with `new Psbt()`
|
|
56
|
+
*
|
|
57
|
+
* Updater: This can be done with `psbt.addInput(input)`, `psbt.addInputs(inputs)`,
|
|
58
|
+
* `psbt.addOutput(output)`, `psbt.addOutputs(outputs)` when you are looking to
|
|
59
|
+
* add new inputs and outputs to the PSBT, and `psbt.updateGlobal(itemObject)`,
|
|
60
|
+
* `psbt.updateInput(itemObject)`, `psbt.updateOutput(itemObject)`
|
|
61
|
+
* addInput requires hash: Buffer | string; and index: number; as attributes
|
|
62
|
+
* and can also include any attributes that are used in updateInput method.
|
|
63
|
+
* addOutput requires script: Buffer; and value: number; and likewise can include
|
|
64
|
+
* data for updateOutput.
|
|
65
|
+
* For a list of what attributes should be what types. Check the bip174 library.
|
|
66
|
+
* Also, check the integration tests for some examples of usage.
|
|
67
|
+
*
|
|
68
|
+
* Signer: There are a few methods. signAllInputs and signAllInputsAsync, which will search all input
|
|
69
|
+
* information for your pubkey or pubkeyhash, and only sign inputs where it finds
|
|
70
|
+
* your info. Or you can explicitly sign a specific input with signInput and
|
|
71
|
+
* signInputAsync. For the async methods you can create a SignerAsync object
|
|
72
|
+
* and use something like a hardware wallet to sign with. (You must implement this)
|
|
73
|
+
*
|
|
74
|
+
* Combiner: psbts can be combined easily with `psbt.combine(psbt2, psbt3, psbt4 ...)`
|
|
75
|
+
* the psbt calling combine will always have precedence when a conflict occurs.
|
|
76
|
+
* Combine checks if the internal bitcoin transaction is the same, so be sure that
|
|
77
|
+
* all sequences, version, locktime, etc. are the same before combining.
|
|
78
|
+
*
|
|
79
|
+
* Input Finalizer: This role is fairly important. Not only does it need to construct
|
|
80
|
+
* the input scriptSigs and witnesses, but it SHOULD verify the signatures etc.
|
|
81
|
+
* Before running `psbt.finalizeAllInputs()` please run `psbt.validateSignaturesOfAllInputs()`
|
|
82
|
+
* Running any finalize method will delete any data in the input(s) that are no longer
|
|
83
|
+
* needed due to the finalized scripts containing the information.
|
|
84
|
+
*
|
|
85
|
+
* Transaction Extractor: This role will perform some checks before returning a
|
|
86
|
+
* Transaction object. Such as fee rate not being larger than maximumFeeRate etc.
|
|
87
|
+
*/
|
|
88
|
+
class Psbt {
|
|
89
|
+
static fromBase64(data, opts = {}) {
|
|
90
|
+
const buffer = tools.fromBase64(data);
|
|
91
|
+
return this.fromBuffer(buffer, opts);
|
|
92
|
+
}
|
|
93
|
+
static fromHex(data, opts = {}) {
|
|
94
|
+
const buffer = tools.fromHex(data);
|
|
95
|
+
return this.fromBuffer(buffer, opts);
|
|
96
|
+
}
|
|
97
|
+
static fromBuffer(buffer, opts = {}) {
|
|
98
|
+
const psbtBase = bip174_1.Psbt.fromBuffer(buffer, transactionFromBuffer);
|
|
99
|
+
const psbt = new Psbt(opts, psbtBase);
|
|
100
|
+
checkTxForDupeIns(psbt.__CACHE.__TX, psbt.__CACHE);
|
|
101
|
+
return psbt;
|
|
102
|
+
}
|
|
103
|
+
constructor(opts = {}, data = new bip174_1.Psbt(new PsbtTransaction())) {
|
|
104
|
+
this.data = data;
|
|
105
|
+
// set defaults
|
|
106
|
+
this.opts = Object.assign({}, DEFAULT_OPTS, opts);
|
|
107
|
+
this.__CACHE = {
|
|
108
|
+
__TX_IN_CACHE: {},
|
|
109
|
+
__TX: this.data.globalMap.unsignedTx.tx,
|
|
110
|
+
// Psbt's predecessor (TransactionBuilder - now removed) behavior
|
|
111
|
+
// was to not confirm input values before signing.
|
|
112
|
+
// Even though we highly encourage people to get
|
|
113
|
+
// the full parent transaction to verify values, the ability to
|
|
114
|
+
// sign non-segwit inputs without the full transaction was often
|
|
115
|
+
// requested. So the only way to activate is to use @ts-ignore.
|
|
116
|
+
// We will disable exporting the Psbt when unsafe sign is active.
|
|
117
|
+
// because it is not BIP174 compliant.
|
|
118
|
+
__UNSAFE_SIGN_NONSEGWIT: false,
|
|
119
|
+
};
|
|
120
|
+
//if (this.data.inputs.length === 0) this.setVersion(2);
|
|
121
|
+
for (let i = 0; i < this.__CACHE.__TX.inputs.length; i++) {
|
|
122
|
+
const input = this.__CACHE.__TX.inputs[i];
|
|
123
|
+
if (!this.data.inputs[i] || !this.data.inputs[i].opcatUtxo) {
|
|
124
|
+
throw new Error('invalid pbst input');
|
|
125
|
+
}
|
|
126
|
+
input.output = new opcat_1.Transaction.Output({
|
|
127
|
+
satoshis: Number(this.data.inputs[i].opcatUtxo.value),
|
|
128
|
+
script: new opcat_1.Script(Buffer.from(this.data.inputs[i].opcatUtxo.script)),
|
|
129
|
+
data: Buffer.from(this.data.inputs[i].opcatUtxo.data),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
// Make data hidden when enumerating
|
|
133
|
+
const dpew = (obj, attr, enumerable, writable) => Object.defineProperty(obj, attr, {
|
|
134
|
+
enumerable,
|
|
135
|
+
writable,
|
|
136
|
+
});
|
|
137
|
+
dpew(this, '__CACHE', false, true);
|
|
138
|
+
dpew(this, 'opts', false, true);
|
|
139
|
+
}
|
|
140
|
+
get inputCount() {
|
|
141
|
+
return this.data.inputs.length;
|
|
142
|
+
}
|
|
143
|
+
get version() {
|
|
144
|
+
return this.__CACHE.__TX.version;
|
|
145
|
+
}
|
|
146
|
+
set version(version) {
|
|
147
|
+
this.setVersion(version);
|
|
148
|
+
}
|
|
149
|
+
get locktime() {
|
|
150
|
+
return this.__CACHE.__TX.version;
|
|
151
|
+
}
|
|
152
|
+
set locktime(locktime) {
|
|
153
|
+
this.setLocktime(locktime);
|
|
154
|
+
}
|
|
155
|
+
get txInputs() {
|
|
156
|
+
return this.__CACHE.__TX.inputs.map(input => ({
|
|
157
|
+
hash: Buffer.from(input.prevTxId).reverse(),
|
|
158
|
+
index: input.outputIndex,
|
|
159
|
+
sequence: input.sequenceNumber,
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
get txOutputs() {
|
|
163
|
+
return this.__CACHE.__TX.outputs.map(output => {
|
|
164
|
+
let address;
|
|
165
|
+
try {
|
|
166
|
+
address = opcat_1.Address.fromHex(output.script.toHex(), this.opts.network);
|
|
167
|
+
// eslint-disable-next-line no-empty
|
|
168
|
+
}
|
|
169
|
+
catch (_) { }
|
|
170
|
+
return {
|
|
171
|
+
script: (0, bufferutils_js_1.cloneBuffer)(output.script.toBuffer()),
|
|
172
|
+
value: BigInt(output.satoshis),
|
|
173
|
+
data: output.data || new Uint8Array(),
|
|
174
|
+
address,
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
combine(...those) {
|
|
179
|
+
this.data.combine(...those.map(o => o.data));
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
clone() {
|
|
183
|
+
// TODO: more efficient cloning
|
|
184
|
+
const res = Psbt.fromBuffer(this.data.toBuffer());
|
|
185
|
+
res.opts = JSON.parse(JSON.stringify(this.opts));
|
|
186
|
+
return res;
|
|
187
|
+
}
|
|
188
|
+
setMaximumFeeRate(satoshiPerByte) {
|
|
189
|
+
check32Bit(satoshiPerByte); // 42.9 BTC per byte IS excessive... so throw
|
|
190
|
+
this.opts.maximumFeeRate = satoshiPerByte;
|
|
191
|
+
}
|
|
192
|
+
setVersion(version) {
|
|
193
|
+
check32Bit(version);
|
|
194
|
+
checkInputsForPartialSig(this.data.inputs, 'setVersion');
|
|
195
|
+
const c = this.__CACHE;
|
|
196
|
+
c.__TX.version = version;
|
|
197
|
+
c.__EXTRACTED_TX = undefined;
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
200
|
+
setLocktime(locktime) {
|
|
201
|
+
check32Bit(locktime);
|
|
202
|
+
checkInputsForPartialSig(this.data.inputs, 'setLocktime');
|
|
203
|
+
const c = this.__CACHE;
|
|
204
|
+
c.__TX.nLockTime = locktime;
|
|
205
|
+
c.__EXTRACTED_TX = undefined;
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
setInputSequence(inputIndex, sequence) {
|
|
209
|
+
check32Bit(sequence);
|
|
210
|
+
checkInputsForPartialSig(this.data.inputs, 'setInputSequence');
|
|
211
|
+
const c = this.__CACHE;
|
|
212
|
+
if (c.__TX.inputs.length <= inputIndex) {
|
|
213
|
+
throw new Error('Input index too high');
|
|
214
|
+
}
|
|
215
|
+
c.__TX.inputs[inputIndex].sequenceNumber = sequence;
|
|
216
|
+
c.__EXTRACTED_TX = undefined;
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
addInputs(inputDatas) {
|
|
220
|
+
inputDatas.forEach(inputData => this.addInput(inputData));
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
addInput(inputData) {
|
|
224
|
+
if (arguments.length > 1 ||
|
|
225
|
+
!inputData ||
|
|
226
|
+
inputData.hash === undefined ||
|
|
227
|
+
inputData.index === undefined ||
|
|
228
|
+
inputData.opcatUtxo === undefined) {
|
|
229
|
+
throw new Error(`Invalid arguments for Psbt.addInput. ` +
|
|
230
|
+
`Requires single object with at least [hash] and [index] and [opcatUtxo]`);
|
|
231
|
+
}
|
|
232
|
+
checkInputsForPartialSig(this.data.inputs, 'addInput');
|
|
233
|
+
const c = this.__CACHE;
|
|
234
|
+
this.data.addInput(inputData);
|
|
235
|
+
const txIn = c.__TX.inputs[c.__TX.inputs.length - 1];
|
|
236
|
+
checkTxInputCache(c, txIn);
|
|
237
|
+
c.__FEE = undefined;
|
|
238
|
+
c.__FEE_RATE = undefined;
|
|
239
|
+
c.__EXTRACTED_TX = undefined;
|
|
240
|
+
return this;
|
|
241
|
+
}
|
|
242
|
+
addOutputs(outputDatas) {
|
|
243
|
+
outputDatas.forEach(outputData => this.addOutput(outputData));
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
addOutput(outputData) {
|
|
247
|
+
if (arguments.length > 1 ||
|
|
248
|
+
!outputData ||
|
|
249
|
+
outputData.value === undefined ||
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
251
|
+
(outputData.address === undefined &&
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
outputData.script === undefined &&
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
255
|
+
outputData.data === undefined)) {
|
|
256
|
+
throw new Error(`Invalid arguments for Psbt.addOutput. ` +
|
|
257
|
+
`Requires single object with at least [script or address] and [value]`);
|
|
258
|
+
}
|
|
259
|
+
checkInputsForPartialSig(this.data.inputs, 'addOutput');
|
|
260
|
+
const { address } = outputData;
|
|
261
|
+
if (typeof address === 'string') {
|
|
262
|
+
const script = opcat_1.Script.fromAddress(address);
|
|
263
|
+
outputData = Object.assign({}, outputData, { script });
|
|
264
|
+
}
|
|
265
|
+
const c = this.__CACHE;
|
|
266
|
+
this.data.addOutput(outputData);
|
|
267
|
+
c.__FEE = undefined;
|
|
268
|
+
c.__FEE_RATE = undefined;
|
|
269
|
+
c.__EXTRACTED_TX = undefined;
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
extractTransaction(disableFeeCheck) {
|
|
273
|
+
if (!this.data.inputs.every(isFinalized))
|
|
274
|
+
throw new Error('Not finalized');
|
|
275
|
+
const c = this.__CACHE;
|
|
276
|
+
if (!disableFeeCheck) {
|
|
277
|
+
checkFees(this, c, this.opts);
|
|
278
|
+
}
|
|
279
|
+
if (c.__EXTRACTED_TX)
|
|
280
|
+
return c.__EXTRACTED_TX;
|
|
281
|
+
const tx = c.__TX.clone();
|
|
282
|
+
inputFinalizeGetAmts(this.data.inputs, tx, c, true);
|
|
283
|
+
return tx;
|
|
284
|
+
}
|
|
285
|
+
getFeeRate() {
|
|
286
|
+
return getTxCacheValue('__FEE_RATE', 'fee rate', this.data.inputs, this.__CACHE);
|
|
287
|
+
}
|
|
288
|
+
getFee() {
|
|
289
|
+
return getTxCacheValue('__FEE', 'fee', this.data.inputs, this.__CACHE);
|
|
290
|
+
}
|
|
291
|
+
finalizeAllInputs() {
|
|
292
|
+
(0, bip174_2.checkForInput)(this.data.inputs, 0); // making sure we have at least one
|
|
293
|
+
range(this.data.inputs.length).forEach(idx => this.finalizeInput(idx));
|
|
294
|
+
return this;
|
|
295
|
+
}
|
|
296
|
+
finalizeInput(inputIndex, finalScriptsFunc) {
|
|
297
|
+
const input = (0, bip174_2.checkForInput)(this.data.inputs, inputIndex);
|
|
298
|
+
return this._finalizeInput(inputIndex, input, finalScriptsFunc);
|
|
299
|
+
}
|
|
300
|
+
_finalizeInput(inputIndex, input, finalScriptsFunc = getFinalScripts) {
|
|
301
|
+
const { script } = getScriptFromInput(inputIndex, input, this.__CACHE);
|
|
302
|
+
if (!script)
|
|
303
|
+
throw new Error(`No script found for input #${inputIndex}`);
|
|
304
|
+
checkPartialSigSighashes(input);
|
|
305
|
+
const { finalScriptSig } = finalScriptsFunc(inputIndex, input, script);
|
|
306
|
+
if (finalScriptSig)
|
|
307
|
+
this.data.updateInput(inputIndex, { finalScriptSig });
|
|
308
|
+
else
|
|
309
|
+
throw new Error(`Unknown error finalizing input #${inputIndex}`);
|
|
310
|
+
this.data.clearFinalizedInput(inputIndex);
|
|
311
|
+
return this;
|
|
312
|
+
}
|
|
313
|
+
getInputType(inputIndex) {
|
|
314
|
+
const input = (0, bip174_2.checkForInput)(this.data.inputs, inputIndex);
|
|
315
|
+
const script = getScriptFromUtxo(inputIndex, input, this.__CACHE);
|
|
316
|
+
const result = getMeaningfulScript(script);
|
|
317
|
+
const type = result.type === 'raw' ? '' : result.type + '-';
|
|
318
|
+
const mainType = classifyScript(result.meaningfulScript);
|
|
319
|
+
return (type + mainType);
|
|
320
|
+
}
|
|
321
|
+
inputHasPubkey(inputIndex, pubkey) {
|
|
322
|
+
const input = (0, bip174_2.checkForInput)(this.data.inputs, inputIndex);
|
|
323
|
+
return pubkeyInInput(pubkey, input, inputIndex, this.__CACHE);
|
|
324
|
+
}
|
|
325
|
+
inputHasHDKey(inputIndex, root) {
|
|
326
|
+
const input = (0, bip174_2.checkForInput)(this.data.inputs, inputIndex);
|
|
327
|
+
const derivationIsMine = bip32DerivationIsMine(root);
|
|
328
|
+
return (!!input.bip32Derivation && input.bip32Derivation.some(derivationIsMine));
|
|
329
|
+
}
|
|
330
|
+
outputHasPubkey(outputIndex, pubkey) {
|
|
331
|
+
return pubkeyInOutput(pubkey, outputIndex, this.__CACHE);
|
|
332
|
+
}
|
|
333
|
+
outputHasHDKey(outputIndex, root) {
|
|
334
|
+
const output = (0, bip174_2.checkForOutput)(this.data.outputs, outputIndex);
|
|
335
|
+
const derivationIsMine = bip32DerivationIsMine(root);
|
|
336
|
+
return (!!output.bip32Derivation && output.bip32Derivation.some(derivationIsMine));
|
|
337
|
+
}
|
|
338
|
+
validateSignaturesOfAllInputs(validator) {
|
|
339
|
+
(0, bip174_2.checkForInput)(this.data.inputs, 0); // making sure we have at least one
|
|
340
|
+
const results = range(this.data.inputs.length).map(idx => this.validateSignaturesOfInput(idx, validator));
|
|
341
|
+
return results.reduce((final, res) => res === true && final, true);
|
|
342
|
+
}
|
|
343
|
+
validateSignaturesOfInput(inputIndex, validator, pubkey) {
|
|
344
|
+
return this._validateSignaturesOfInput(inputIndex, validator, pubkey);
|
|
345
|
+
}
|
|
346
|
+
_validateSignaturesOfInput(inputIndex, validator, pubkey) {
|
|
347
|
+
const input = this.data.inputs[inputIndex];
|
|
348
|
+
const partialSig = (input || {}).partialSig;
|
|
349
|
+
if (!input || !partialSig || partialSig.length < 1)
|
|
350
|
+
throw new Error('No signatures to validate');
|
|
351
|
+
if (typeof validator !== 'function')
|
|
352
|
+
throw new Error('Need validator function to validate signatures');
|
|
353
|
+
const mySigs = pubkey
|
|
354
|
+
? partialSig.filter(sig => tools.compare(sig.pubkey, pubkey) === 0)
|
|
355
|
+
: partialSig;
|
|
356
|
+
if (mySigs.length < 1)
|
|
357
|
+
throw new Error('No signatures for this pubkey');
|
|
358
|
+
const results = [];
|
|
359
|
+
let hashCache;
|
|
360
|
+
let scriptCache;
|
|
361
|
+
let sighashCache;
|
|
362
|
+
for (const pSig of mySigs) {
|
|
363
|
+
const sig = signatureutils.decode(pSig.signature);
|
|
364
|
+
const { hash, script } = sighashCache !== sig.hashType
|
|
365
|
+
? getHashForSig(inputIndex, Object.assign({}, input, { sighashType: sig.hashType }), this.__CACHE)
|
|
366
|
+
: { hash: hashCache, script: scriptCache };
|
|
367
|
+
sighashCache = sig.hashType;
|
|
368
|
+
hashCache = hash;
|
|
369
|
+
scriptCache = script;
|
|
370
|
+
checkScriptForPubkey(pSig.pubkey, script, 'verify');
|
|
371
|
+
results.push(validator(pSig.pubkey, hash, sig.signature));
|
|
372
|
+
}
|
|
373
|
+
return results.every(res => res === true);
|
|
374
|
+
}
|
|
375
|
+
signAllInputsHD(hdKeyPair, sighashTypes = [opcat_1.crypto.Signature.SIGHASH_ALL]) {
|
|
376
|
+
if (!hdKeyPair || !hdKeyPair.publicKey || !hdKeyPair.fingerprint) {
|
|
377
|
+
throw new Error('Need HDSigner to sign input');
|
|
378
|
+
}
|
|
379
|
+
const results = [];
|
|
380
|
+
for (const i of range(this.data.inputs.length)) {
|
|
381
|
+
try {
|
|
382
|
+
this.signInputHD(i, hdKeyPair, sighashTypes);
|
|
383
|
+
results.push(true);
|
|
384
|
+
}
|
|
385
|
+
catch (_) {
|
|
386
|
+
results.push(false);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (results.every(v => v === false)) {
|
|
390
|
+
throw new Error('No inputs were signed');
|
|
391
|
+
}
|
|
392
|
+
return this;
|
|
393
|
+
}
|
|
394
|
+
signAllInputsHDAsync(hdKeyPair, sighashTypes = [opcat_1.crypto.Signature.SIGHASH_ALL]) {
|
|
395
|
+
return new Promise((resolve, reject) => {
|
|
396
|
+
if (!hdKeyPair || !hdKeyPair.publicKey || !hdKeyPair.fingerprint) {
|
|
397
|
+
return reject(new Error('Need HDSigner to sign input'));
|
|
398
|
+
}
|
|
399
|
+
const results = [];
|
|
400
|
+
const promises = [];
|
|
401
|
+
for (const i of range(this.data.inputs.length)) {
|
|
402
|
+
promises.push(this.signInputHDAsync(i, hdKeyPair, sighashTypes).then(() => {
|
|
403
|
+
results.push(true);
|
|
404
|
+
}, () => {
|
|
405
|
+
results.push(false);
|
|
406
|
+
}));
|
|
407
|
+
}
|
|
408
|
+
return Promise.all(promises).then(() => {
|
|
409
|
+
if (results.every(v => v === false)) {
|
|
410
|
+
return reject(new Error('No inputs were signed'));
|
|
411
|
+
}
|
|
412
|
+
resolve();
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
signInputHD(inputIndex, hdKeyPair, sighashTypes = [opcat_1.crypto.Signature.SIGHASH_ALL]) {
|
|
417
|
+
if (!hdKeyPair || !hdKeyPair.publicKey || !hdKeyPair.fingerprint) {
|
|
418
|
+
throw new Error('Need HDSigner to sign input');
|
|
419
|
+
}
|
|
420
|
+
const signers = getSignersFromHD(inputIndex, this.data.inputs, hdKeyPair);
|
|
421
|
+
signers.forEach(signer => this.signInput(inputIndex, signer, sighashTypes));
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
signInputHDAsync(inputIndex, hdKeyPair, sighashTypes = [opcat_1.crypto.Signature.SIGHASH_ALL]) {
|
|
425
|
+
return new Promise((resolve, reject) => {
|
|
426
|
+
if (!hdKeyPair || !hdKeyPair.publicKey || !hdKeyPair.fingerprint) {
|
|
427
|
+
return reject(new Error('Need HDSigner to sign input'));
|
|
428
|
+
}
|
|
429
|
+
const signers = getSignersFromHD(inputIndex, this.data.inputs, hdKeyPair);
|
|
430
|
+
const promises = signers.map(signer => this.signInputAsync(inputIndex, signer, sighashTypes));
|
|
431
|
+
return Promise.all(promises)
|
|
432
|
+
.then(() => {
|
|
433
|
+
resolve();
|
|
434
|
+
})
|
|
435
|
+
.catch(reject);
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
signAllInputs(keyPair, sighashTypes) {
|
|
439
|
+
if (!keyPair || !keyPair.publicKey)
|
|
440
|
+
throw new Error('Need Signer to sign input');
|
|
441
|
+
// TODO: Add a pubkey/pubkeyhash cache to each input
|
|
442
|
+
// as input information is added, then eventually
|
|
443
|
+
// optimize this method.
|
|
444
|
+
const results = [];
|
|
445
|
+
for (const i of range(this.data.inputs.length)) {
|
|
446
|
+
try {
|
|
447
|
+
this.signInput(i, keyPair, sighashTypes);
|
|
448
|
+
results.push(true);
|
|
449
|
+
}
|
|
450
|
+
catch (_) {
|
|
451
|
+
results.push(false);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (results.every(v => v === false)) {
|
|
455
|
+
throw new Error('No inputs were signed');
|
|
456
|
+
}
|
|
457
|
+
return this;
|
|
458
|
+
}
|
|
459
|
+
signAllInputsAsync(keyPair, sighashTypes) {
|
|
460
|
+
return new Promise((resolve, reject) => {
|
|
461
|
+
if (!keyPair || !keyPair.publicKey)
|
|
462
|
+
return reject(new Error('Need Signer to sign input'));
|
|
463
|
+
// TODO: Add a pubkey/pubkeyhash cache to each input
|
|
464
|
+
// as input information is added, then eventually
|
|
465
|
+
// optimize this method.
|
|
466
|
+
const results = [];
|
|
467
|
+
const promises = [];
|
|
468
|
+
for (const [i] of this.data.inputs.entries()) {
|
|
469
|
+
promises.push(this.signInputAsync(i, keyPair, sighashTypes).then(() => {
|
|
470
|
+
results.push(true);
|
|
471
|
+
}, () => {
|
|
472
|
+
results.push(false);
|
|
473
|
+
}));
|
|
474
|
+
}
|
|
475
|
+
return Promise.all(promises).then(() => {
|
|
476
|
+
if (results.every(v => v === false)) {
|
|
477
|
+
return reject(new Error('No inputs were signed'));
|
|
478
|
+
}
|
|
479
|
+
resolve();
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
signInput(inputIndex, keyPair, sighashTypes) {
|
|
484
|
+
if (!keyPair || !keyPair.publicKey)
|
|
485
|
+
throw new Error('Need Signer to sign input');
|
|
486
|
+
return this._signInput(inputIndex, keyPair, sighashTypes);
|
|
487
|
+
}
|
|
488
|
+
_signInput(inputIndex, keyPair, sighashTypes = [opcat_1.crypto.Signature.SIGHASH_ALL]) {
|
|
489
|
+
const { hash, sighashType } = getHashAndSighashType(this.data.inputs, inputIndex, keyPair.publicKey, this.__CACHE, sighashTypes);
|
|
490
|
+
const partialSig = [
|
|
491
|
+
{
|
|
492
|
+
pubkey: keyPair.publicKey,
|
|
493
|
+
signature: signatureutils.encode(keyPair.sign(hash), sighashType),
|
|
494
|
+
},
|
|
495
|
+
];
|
|
496
|
+
this.data.updateInput(inputIndex, { partialSig });
|
|
497
|
+
return this;
|
|
498
|
+
}
|
|
499
|
+
signInputAsync(inputIndex, keyPair, sighashTypes) {
|
|
500
|
+
return Promise.resolve().then(() => {
|
|
501
|
+
if (!keyPair || !keyPair.publicKey)
|
|
502
|
+
throw new Error('Need Signer to sign input');
|
|
503
|
+
return this._signInputAsync(inputIndex, keyPair, sighashTypes);
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
_signInputAsync(inputIndex, keyPair, sighashTypes = [opcat_1.crypto.Signature.SIGHASH_ALL]) {
|
|
507
|
+
const { hash, sighashType } = getHashAndSighashType(this.data.inputs, inputIndex, keyPair.publicKey, this.__CACHE, sighashTypes);
|
|
508
|
+
return Promise.resolve(keyPair.sign(hash)).then(signature => {
|
|
509
|
+
const partialSig = [
|
|
510
|
+
{
|
|
511
|
+
pubkey: keyPair.publicKey,
|
|
512
|
+
signature: signatureutils.encode(signature, sighashType),
|
|
513
|
+
},
|
|
514
|
+
];
|
|
515
|
+
this.data.updateInput(inputIndex, { partialSig });
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
toBuffer() {
|
|
519
|
+
checkCache(this.__CACHE);
|
|
520
|
+
return this.data.toBuffer();
|
|
521
|
+
}
|
|
522
|
+
toHex() {
|
|
523
|
+
checkCache(this.__CACHE);
|
|
524
|
+
return this.data.toHex();
|
|
525
|
+
}
|
|
526
|
+
toBase64() {
|
|
527
|
+
checkCache(this.__CACHE);
|
|
528
|
+
return this.data.toBase64();
|
|
529
|
+
}
|
|
530
|
+
updateGlobal(updateData) {
|
|
531
|
+
this.data.updateGlobal(updateData);
|
|
532
|
+
return this;
|
|
533
|
+
}
|
|
534
|
+
updateInput(inputIndex, updateData) {
|
|
535
|
+
this.data.updateInput(inputIndex, updateData);
|
|
536
|
+
return this;
|
|
537
|
+
}
|
|
538
|
+
updateOutput(outputIndex, updateData) {
|
|
539
|
+
this.data.updateOutput(outputIndex, updateData);
|
|
540
|
+
return this;
|
|
541
|
+
}
|
|
542
|
+
addUnknownKeyValToGlobal(keyVal) {
|
|
543
|
+
this.data.addUnknownKeyValToGlobal(keyVal);
|
|
544
|
+
return this;
|
|
545
|
+
}
|
|
546
|
+
addUnknownKeyValToInput(inputIndex, keyVal) {
|
|
547
|
+
this.data.addUnknownKeyValToInput(inputIndex, keyVal);
|
|
548
|
+
return this;
|
|
549
|
+
}
|
|
550
|
+
addUnknownKeyValToOutput(outputIndex, keyVal) {
|
|
551
|
+
this.data.addUnknownKeyValToOutput(outputIndex, keyVal);
|
|
552
|
+
return this;
|
|
553
|
+
}
|
|
554
|
+
clearFinalizedInput(inputIndex) {
|
|
555
|
+
this.data.clearFinalizedInput(inputIndex);
|
|
556
|
+
return this;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
exports.Psbt = Psbt;
|
|
560
|
+
/**
|
|
561
|
+
* This function is needed to pass to the bip174 base class's fromBuffer.
|
|
562
|
+
* It takes the "transaction buffer" portion of the psbt buffer and returns a
|
|
563
|
+
* Transaction (From the bip174 library) interface.
|
|
564
|
+
*/
|
|
565
|
+
const transactionFromBuffer = (buffer) => new PsbtTransaction(buffer);
|
|
566
|
+
/**
|
|
567
|
+
* This class implements the Transaction interface from bip174 library.
|
|
568
|
+
* It contains a bitcoinjs-lib Transaction object.
|
|
569
|
+
*/
|
|
570
|
+
class PsbtTransaction {
|
|
571
|
+
constructor(buffer = Uint8Array.from([1, 0, 0, 0, 0, 0, 0, 0, 0, 0])) {
|
|
572
|
+
this.tx = opcat_1.Transaction.fromBuffer(Buffer.from(buffer));
|
|
573
|
+
checkTxEmpty(this.tx);
|
|
574
|
+
Object.defineProperty(this, 'tx', {
|
|
575
|
+
enumerable: false,
|
|
576
|
+
writable: true,
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
getInputOutputCounts() {
|
|
580
|
+
return {
|
|
581
|
+
inputCount: this.tx.inputs.length,
|
|
582
|
+
outputCount: this.tx.outputs.length,
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
addInput(input) {
|
|
586
|
+
if (input.hash === undefined ||
|
|
587
|
+
input.index === undefined ||
|
|
588
|
+
input.opcatUtxo === undefined ||
|
|
589
|
+
(!(input.hash instanceof Uint8Array) &&
|
|
590
|
+
typeof input.hash !== 'string') ||
|
|
591
|
+
typeof input.index !== 'number') {
|
|
592
|
+
throw new Error('Error adding input.');
|
|
593
|
+
}
|
|
594
|
+
const prevTxId = typeof input.hash === 'string'
|
|
595
|
+
? input.hash
|
|
596
|
+
: (0, bufferutils_js_1.reverseBuffer)(tools.fromHex(input.hash));
|
|
597
|
+
this.tx.addInput(new opcat_1.Transaction.Input({
|
|
598
|
+
prevTxId: prevTxId,
|
|
599
|
+
outputIndex: input.index,
|
|
600
|
+
sequenceNumber: input.sequence
|
|
601
|
+
}), opcat_1.Script.fromBuffer(Buffer.from(input.opcatUtxo.script)), Number(input.opcatUtxo.value), Buffer.from(input.opcatUtxo.data));
|
|
602
|
+
}
|
|
603
|
+
addOutput(output) {
|
|
604
|
+
if (output.script === undefined ||
|
|
605
|
+
output.data === undefined ||
|
|
606
|
+
output.value === undefined ||
|
|
607
|
+
!(output.script instanceof Uint8Array) ||
|
|
608
|
+
!(output.data instanceof Uint8Array) ||
|
|
609
|
+
typeof output.value !== 'bigint') {
|
|
610
|
+
throw new Error('Error adding output.');
|
|
611
|
+
}
|
|
612
|
+
this.tx.addOutput(new opcat_1.Transaction.Output({
|
|
613
|
+
script: output.script,
|
|
614
|
+
satoshis: Number(output.value),
|
|
615
|
+
data: Buffer.from(output.data),
|
|
616
|
+
}));
|
|
617
|
+
}
|
|
618
|
+
toBuffer() {
|
|
619
|
+
return this.tx.toBuffer();
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
function canFinalize(input, script, scriptType) {
|
|
623
|
+
switch (scriptType) {
|
|
624
|
+
case 'pubkey':
|
|
625
|
+
case 'pubkeyhash':
|
|
626
|
+
return hasSigs(1, input.partialSig);
|
|
627
|
+
case 'multisig':
|
|
628
|
+
{
|
|
629
|
+
const ls = opcat_1.Script.fromBuffer(Buffer.from(script));
|
|
630
|
+
if (!ls.isMultisigOut()) {
|
|
631
|
+
throw new Error('Script is not a multisig output');
|
|
632
|
+
}
|
|
633
|
+
const p2ms = ls.decodeMultisigOut();
|
|
634
|
+
return hasSigs(p2ms.m, input.partialSig, p2ms.pubkeys);
|
|
635
|
+
}
|
|
636
|
+
default:
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
function checkCache(cache) {
|
|
641
|
+
if (cache.__UNSAFE_SIGN_NONSEGWIT !== false) {
|
|
642
|
+
throw new Error('Not BIP174 compliant, can not export');
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function hasSigs(neededSigs, partialSig, pubkeys) {
|
|
646
|
+
if (!partialSig)
|
|
647
|
+
return false;
|
|
648
|
+
let sigs;
|
|
649
|
+
if (pubkeys) {
|
|
650
|
+
sigs = pubkeys
|
|
651
|
+
.map(pkey => {
|
|
652
|
+
const pubkey = compressPubkey(pkey);
|
|
653
|
+
return partialSig.find(pSig => tools.compare(pSig.pubkey, pubkey) === 0);
|
|
654
|
+
})
|
|
655
|
+
.filter(v => !!v);
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
sigs = partialSig;
|
|
659
|
+
}
|
|
660
|
+
if (sigs.length > neededSigs)
|
|
661
|
+
throw new Error('Too many signatures');
|
|
662
|
+
return sigs.length === neededSigs;
|
|
663
|
+
}
|
|
664
|
+
function isFinalized(input) {
|
|
665
|
+
return !!input.finalScriptSig || !!input.finalScriptWitness;
|
|
666
|
+
}
|
|
667
|
+
exports.isFinalized = isFinalized;
|
|
668
|
+
function bip32DerivationIsMine(root) {
|
|
669
|
+
return (d) => {
|
|
670
|
+
if (tools.compare(root.fingerprint, d.masterFingerprint))
|
|
671
|
+
return false;
|
|
672
|
+
if (tools.compare(root.derivePath(d.path).publicKey, d.pubkey))
|
|
673
|
+
return false;
|
|
674
|
+
return true;
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
function check32Bit(num) {
|
|
678
|
+
if (typeof num !== 'number' ||
|
|
679
|
+
num !== Math.floor(num) ||
|
|
680
|
+
num > 0xffffffff ||
|
|
681
|
+
num < 0) {
|
|
682
|
+
throw new Error('Invalid 32 bit integer');
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
function checkFees(psbt, cache, opts) {
|
|
686
|
+
const feeRate = cache.__FEE_RATE || psbt.getFeeRate();
|
|
687
|
+
const vsize = cache.__EXTRACTED_TX.getEstimateSize();
|
|
688
|
+
const satoshis = feeRate * vsize;
|
|
689
|
+
if (feeRate >= opts.maximumFeeRate) {
|
|
690
|
+
throw new Error(`Warning: You are paying around ${(satoshis / 1e8).toFixed(8)} in ` +
|
|
691
|
+
`fees, which is ${feeRate} satoshi per byte for a transaction ` +
|
|
692
|
+
`with a VSize of ${vsize} bytes (segwit counted as 0.25 byte per ` +
|
|
693
|
+
`byte). Use setMaximumFeeRate method to raise your threshold, or ` +
|
|
694
|
+
`pass true to the first arg of extractTransaction.`);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
function checkInputsForPartialSig(inputs, action) {
|
|
698
|
+
inputs.forEach(input => {
|
|
699
|
+
const throws = (0, psbtutils_js_1.checkInputForSig)(input, action);
|
|
700
|
+
if (throws)
|
|
701
|
+
throw new Error('Can not modify transaction, signatures exist.');
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function checkPartialSigSighashes(input) {
|
|
705
|
+
if (!input.sighashType || !input.partialSig)
|
|
706
|
+
return;
|
|
707
|
+
const { partialSig, sighashType } = input;
|
|
708
|
+
partialSig.forEach((pSig) => {
|
|
709
|
+
const { hashType } = signatureutils.decode(pSig.signature);
|
|
710
|
+
if (sighashType !== hashType) {
|
|
711
|
+
throw new Error('Signature sighash does not match input sighash type');
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
function checkScriptForPubkey(pubkey, script, action) {
|
|
716
|
+
if (!(0, psbtutils_js_1.pubkeyInScript)(pubkey, script)) {
|
|
717
|
+
throw new Error(`Can not ${action} for this input with the key ${tools.toHex(pubkey)}`);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
function checkTxEmpty(tx) {
|
|
721
|
+
const isEmpty = tx.inputs.every(input => input.script &&
|
|
722
|
+
input.script.length === 0);
|
|
723
|
+
if (!isEmpty) {
|
|
724
|
+
throw new Error('Format Error: Transaction ScriptSigs are not empty');
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
function checkTxForDupeIns(tx, cache) {
|
|
728
|
+
tx.inputs.forEach(input => {
|
|
729
|
+
checkTxInputCache(cache, input);
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
function checkTxInputCache(cache, input) {
|
|
733
|
+
const key = tools.toHex((0, bufferutils_js_1.reverseBuffer)(Uint8Array.from(input.prevTxId))) + ':' + input.outputIndex;
|
|
734
|
+
if (cache.__TX_IN_CACHE[key])
|
|
735
|
+
throw new Error('Duplicate input detected.');
|
|
736
|
+
cache.__TX_IN_CACHE[key] = 1;
|
|
737
|
+
}
|
|
738
|
+
function getTxCacheValue(key, name, inputs, c) {
|
|
739
|
+
if (!inputs.every(isFinalized))
|
|
740
|
+
throw new Error(`PSBT must be finalized to calculate ${name}`);
|
|
741
|
+
if (key === '__FEE_RATE' && c.__FEE_RATE)
|
|
742
|
+
return c.__FEE_RATE;
|
|
743
|
+
if (key === '__FEE' && c.__FEE)
|
|
744
|
+
return c.__FEE;
|
|
745
|
+
let tx;
|
|
746
|
+
let mustFinalize = true;
|
|
747
|
+
if (c.__EXTRACTED_TX) {
|
|
748
|
+
tx = c.__EXTRACTED_TX;
|
|
749
|
+
mustFinalize = false;
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
tx = c.__TX.clone();
|
|
753
|
+
}
|
|
754
|
+
inputFinalizeGetAmts(inputs, tx, c, mustFinalize);
|
|
755
|
+
if (key === '__FEE_RATE')
|
|
756
|
+
return c.__FEE_RATE;
|
|
757
|
+
else if (key === '__FEE')
|
|
758
|
+
return c.__FEE;
|
|
759
|
+
return undefined;
|
|
760
|
+
}
|
|
761
|
+
function getFinalScripts(inputIndex, input, script) {
|
|
762
|
+
const scriptType = classifyScript(script);
|
|
763
|
+
if (!canFinalize(input, script, scriptType))
|
|
764
|
+
throw new Error(`Can not finalize input #${inputIndex}`);
|
|
765
|
+
return prepareFinalScripts(script, scriptType, input.partialSig);
|
|
766
|
+
}
|
|
767
|
+
function prepareFinalScripts(script, scriptType, partialSig) {
|
|
768
|
+
// Wow, the payments API is very handy
|
|
769
|
+
const us = getUnlockingScript(script, scriptType, partialSig);
|
|
770
|
+
const finalScriptSig = us.toBuffer();
|
|
771
|
+
return {
|
|
772
|
+
finalScriptSig,
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
function getHashAndSighashType(inputs, inputIndex, pubkey, cache, sighashTypes) {
|
|
776
|
+
const input = (0, bip174_2.checkForInput)(inputs, inputIndex);
|
|
777
|
+
const { hash, sighashType, script } = getHashForSig(inputIndex, input, cache, sighashTypes);
|
|
778
|
+
//checkScriptForPubkey(pubkey, script, 'sign');
|
|
779
|
+
return {
|
|
780
|
+
hash,
|
|
781
|
+
sighashType,
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
function getHashForSig(inputIndex, input, cache, sighashTypes) {
|
|
785
|
+
const unsignedTx = cache.__TX;
|
|
786
|
+
const sighashType = input.sighashType || opcat_1.crypto.Signature.SIGHASH_ALL;
|
|
787
|
+
checkSighashTypeAllowed(sighashType, sighashTypes);
|
|
788
|
+
const prevout = unsignedTx.inputs[inputIndex].output;
|
|
789
|
+
const { meaningfulScript } = getMeaningfulScript(prevout.script.toBuffer());
|
|
790
|
+
const hash = unsignedTx.hashForSignature(inputIndex, sighashType);
|
|
791
|
+
return {
|
|
792
|
+
script: meaningfulScript,
|
|
793
|
+
sighashType,
|
|
794
|
+
hash,
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
function checkSighashTypeAllowed(sighashType, sighashTypes) {
|
|
798
|
+
if (sighashTypes && sighashTypes.indexOf(sighashType) < 0) {
|
|
799
|
+
const str = sighashTypeToString(sighashType);
|
|
800
|
+
throw new Error(`Sighash type is not allowed. Retry the sign method passing the ` +
|
|
801
|
+
`sighashTypes array of whitelisted types. Sighash type: ${str}`);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function getUnlockingScript(script, scriptType, partialSig) {
|
|
805
|
+
let unlockingScript;
|
|
806
|
+
switch (scriptType) {
|
|
807
|
+
case 'multisig':
|
|
808
|
+
{
|
|
809
|
+
const sigs = getSortedSigs(script, partialSig);
|
|
810
|
+
unlockingScript = opcat_1.Script.fromASM(`OP_0 ${sigs.map(sig => tools.toHex(sig)).join(' ')}`);
|
|
811
|
+
break;
|
|
812
|
+
}
|
|
813
|
+
case 'pubkey':
|
|
814
|
+
{
|
|
815
|
+
const ls = opcat_1.Script.fromBuffer(Buffer.from(script));
|
|
816
|
+
if (ls.isPublicKeyOut()) {
|
|
817
|
+
unlockingScript = opcat_1.Script.fromASM(`${tools.toHex(partialSig[0].signature)}}`);
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
throw new Error('Can not finalize pubkey script, it is not a valid public key script');
|
|
821
|
+
}
|
|
822
|
+
break;
|
|
823
|
+
}
|
|
824
|
+
case 'pubkeyhash':
|
|
825
|
+
{
|
|
826
|
+
const ls = opcat_1.Script.fromBuffer(Buffer.from(script));
|
|
827
|
+
if (ls.isPublicKeyHashOut()) {
|
|
828
|
+
unlockingScript = opcat_1.Script.fromASM(`${tools.toHex(partialSig[0].signature)} ${tools.toHex(partialSig[0].pubkey)}`);
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
throw new Error('Can not finalize pubkey script, it is not a valid public key hash script');
|
|
832
|
+
}
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
return unlockingScript;
|
|
837
|
+
}
|
|
838
|
+
function getScriptFromInput(_inputIndex, input, _cache) {
|
|
839
|
+
const res = {
|
|
840
|
+
script: null,
|
|
841
|
+
};
|
|
842
|
+
res.script = input.opcatUtxo.script;
|
|
843
|
+
return res;
|
|
844
|
+
}
|
|
845
|
+
function getSignersFromHD(inputIndex, inputs, hdKeyPair) {
|
|
846
|
+
const input = (0, bip174_2.checkForInput)(inputs, inputIndex);
|
|
847
|
+
if (!input.bip32Derivation || input.bip32Derivation.length === 0) {
|
|
848
|
+
throw new Error('Need bip32Derivation to sign with HD');
|
|
849
|
+
}
|
|
850
|
+
const myDerivations = input.bip32Derivation
|
|
851
|
+
.map((bipDv) => {
|
|
852
|
+
if (tools.compare(bipDv.masterFingerprint, hdKeyPair.fingerprint) === 0) {
|
|
853
|
+
return bipDv;
|
|
854
|
+
}
|
|
855
|
+
else {
|
|
856
|
+
return undefined;
|
|
857
|
+
}
|
|
858
|
+
})
|
|
859
|
+
.filter((v) => !!v);
|
|
860
|
+
if (myDerivations.length === 0) {
|
|
861
|
+
throw new Error('Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint');
|
|
862
|
+
}
|
|
863
|
+
const signers = myDerivations.map(bipDv => {
|
|
864
|
+
const node = hdKeyPair.derivePath(bipDv.path);
|
|
865
|
+
if (tools.compare(bipDv.pubkey, node.publicKey) !== 0) {
|
|
866
|
+
throw new Error('pubkey did not match bip32Derivation');
|
|
867
|
+
}
|
|
868
|
+
return node;
|
|
869
|
+
});
|
|
870
|
+
return signers;
|
|
871
|
+
}
|
|
872
|
+
function getSortedSigs(script, partialSig) {
|
|
873
|
+
const ss = opcat_1.Script.fromBuffer(Buffer.from(script));
|
|
874
|
+
const p2ms = ss.decodeMultisigOut();
|
|
875
|
+
// for each pubkey in order of p2ms script
|
|
876
|
+
return p2ms
|
|
877
|
+
.pubkeys.map(pk => {
|
|
878
|
+
// filter partialSig array by pubkey being equal
|
|
879
|
+
return (partialSig.filter(ps => {
|
|
880
|
+
return tools.compare(ps.pubkey, pk) === 0;
|
|
881
|
+
})[0] || {}).signature;
|
|
882
|
+
// Any pubkey without a match will return undefined
|
|
883
|
+
// this last filter removes all the undefined items in the array.
|
|
884
|
+
})
|
|
885
|
+
.filter(v => !!v);
|
|
886
|
+
}
|
|
887
|
+
function sighashTypeToString(sighashType) {
|
|
888
|
+
let text = sighashType & opcat_1.crypto.Signature.SIGHASH_ANYONECANPAY
|
|
889
|
+
? 'SIGHASH_ANYONECANPAY | '
|
|
890
|
+
: '';
|
|
891
|
+
const sigMod = sighashType & 0x1f;
|
|
892
|
+
switch (sigMod) {
|
|
893
|
+
case opcat_1.crypto.Signature.SIGHASH_ALL:
|
|
894
|
+
text += 'SIGHASH_ALL';
|
|
895
|
+
break;
|
|
896
|
+
case opcat_1.crypto.Signature.SIGHASH_SINGLE:
|
|
897
|
+
text += 'SIGHASH_SINGLE';
|
|
898
|
+
break;
|
|
899
|
+
case opcat_1.crypto.Signature.SIGHASH_NONE:
|
|
900
|
+
text += 'SIGHASH_NONE';
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
return text;
|
|
904
|
+
}
|
|
905
|
+
function inputFinalizeGetAmts(inputs, tx, cache, mustFinalize) {
|
|
906
|
+
let inputAmount = 0n;
|
|
907
|
+
inputs.forEach((input, idx) => {
|
|
908
|
+
if (mustFinalize && input.finalScriptSig)
|
|
909
|
+
tx.inputs[idx].setScript(opcat_1.Script.fromBuffer(Buffer.from(input.finalScriptSig)));
|
|
910
|
+
const out = tx.inputs[idx].output;
|
|
911
|
+
inputAmount += BigInt(out.satoshis);
|
|
912
|
+
});
|
|
913
|
+
const outputAmount = tx.outputs.reduce((total, o) => total + BigInt(o.satoshis), 0n);
|
|
914
|
+
const fee = inputAmount - outputAmount;
|
|
915
|
+
if (fee < 0) {
|
|
916
|
+
throw new Error('Outputs are spending more than Inputs');
|
|
917
|
+
}
|
|
918
|
+
const bytes = tx.getEstimateSize();
|
|
919
|
+
cache.__FEE = fee;
|
|
920
|
+
cache.__EXTRACTED_TX = tx;
|
|
921
|
+
cache.__FEE_RATE = Math.floor(Number(fee / BigInt(bytes)));
|
|
922
|
+
}
|
|
923
|
+
function getScriptFromUtxo(inputIndex, input, cache) {
|
|
924
|
+
const { script } = getScriptAndAmountFromUtxo(inputIndex, input, cache);
|
|
925
|
+
return script;
|
|
926
|
+
}
|
|
927
|
+
function getScriptAndAmountFromUtxo(inputIndex, _input, cache) {
|
|
928
|
+
const unsignedTx = cache.__TX;
|
|
929
|
+
const o = unsignedTx.inputs[inputIndex].output;
|
|
930
|
+
return { script: o.script.toBuffer(), value: BigInt(o.satoshis), data: o.data };
|
|
931
|
+
}
|
|
932
|
+
function pubkeyInInput(pubkey, input, inputIndex, cache) {
|
|
933
|
+
const script = getScriptFromUtxo(inputIndex, input, cache);
|
|
934
|
+
const { meaningfulScript } = getMeaningfulScript(script);
|
|
935
|
+
return (0, psbtutils_js_1.pubkeyInScript)(pubkey, meaningfulScript);
|
|
936
|
+
}
|
|
937
|
+
function pubkeyInOutput(pubkey, outputIndex, cache) {
|
|
938
|
+
// const script = cache.__TX.outputs[outputIndex].script;
|
|
939
|
+
// const { meaningfulScript } = getMeaningfulScript(
|
|
940
|
+
// script.toBuffer(),
|
|
941
|
+
// );
|
|
942
|
+
// return pubkeyInScript(pubkey, meaningfulScript);
|
|
943
|
+
return true;
|
|
944
|
+
}
|
|
945
|
+
function compressPubkey(pubkey) {
|
|
946
|
+
if (pubkey.length === 65) {
|
|
947
|
+
const parity = pubkey[64] & 1;
|
|
948
|
+
const newKey = pubkey.slice(0, 33);
|
|
949
|
+
newKey[0] = 2 | parity;
|
|
950
|
+
return newKey;
|
|
951
|
+
}
|
|
952
|
+
return pubkey.slice();
|
|
953
|
+
}
|
|
954
|
+
function getMeaningfulScript(script) {
|
|
955
|
+
return {
|
|
956
|
+
meaningfulScript: script,
|
|
957
|
+
type: 'raw',
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
function classifyScript(script) {
|
|
961
|
+
const _script = opcat_1.Script.fromBuffer(Buffer.from(script));
|
|
962
|
+
if (_script.isPublicKeyHashOut())
|
|
963
|
+
return 'pubkeyhash';
|
|
964
|
+
if (_script.isMultisigOut())
|
|
965
|
+
return 'multisig';
|
|
966
|
+
if (_script.isPublicKeyOut)
|
|
967
|
+
return 'pubkey';
|
|
968
|
+
return 'nonstandard';
|
|
969
|
+
}
|
|
970
|
+
function range(n) {
|
|
971
|
+
return [...Array(n).keys()];
|
|
972
|
+
}
|
|
973
|
+
//# sourceMappingURL=psbt.js.map
|