@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,98 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { method } from '../decorators.js';
|
|
11
|
+
import { assert } from '../fns/assert.js';
|
|
12
|
+
import { SmartContractLib } from '../smartContractLib.js';
|
|
13
|
+
import { TxUtils } from './txUtils.js';
|
|
14
|
+
import { TX_INPUT_BYTE_LEN, TX_OUTPUT_BYTE_LEN, TX_OUTPUT_SATOSHI_BYTE_LEN, TX_OUTPUT_SCRIPT_HASH_LEN } from '../consts.js';
|
|
15
|
+
import { slice } from '../fns/byteString.js';
|
|
16
|
+
import { StdUtils } from './stdUtils.js';
|
|
17
|
+
import { TxHashPreimageUtils } from './txHashPreimageUtils.js';
|
|
18
|
+
/**
|
|
19
|
+
* Library for verifying backtraces all the way to the genesis point.
|
|
20
|
+
* @category Library
|
|
21
|
+
* @onchain
|
|
22
|
+
*/
|
|
23
|
+
export class Backtrace extends SmartContractLib {
|
|
24
|
+
static checkPrevTxHashPreimage(txHashPreimage, t_prevouts, t_inputIndex) {
|
|
25
|
+
const txHash = TxHashPreimageUtils.getTxHashFromTxHashPreimage(txHashPreimage);
|
|
26
|
+
assert(txHash == slice(t_prevouts, t_inputIndex * 36n, t_inputIndex * 36n + 32n), 'prevTxHash mismatch');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Back-to-genesis backtrace verification for a contract which can be backtraced to the genesis outpoint.
|
|
30
|
+
* It will be a valid backtraceInfo if the prevPrevOutpoint is the genesis outpoint or the prevPrevScript is the selfScript.
|
|
31
|
+
* @param backtraceInfo backtrace info to verify, including prevTx and prevPrevTx informations
|
|
32
|
+
* @param t_genesisOutpoint expected genesis outpoint of the contract which usually is a contract property and trustable
|
|
33
|
+
* @param t_selfScript expected self locking script, i.e. this.ctx.spentScript, of the currect spending UTXO context which is trustable
|
|
34
|
+
* @param t_prevTxInputList input list of the prevTx which should be trustable
|
|
35
|
+
*/
|
|
36
|
+
static verifyFromOutpoint(backtraceInfo, t_genesisOutpoint, t_selfScript, t_prevTxInputList) {
|
|
37
|
+
const res = Backtrace.verifyChainTxs(backtraceInfo, t_prevTxInputList);
|
|
38
|
+
assert(res.prevPrevOutpoint === t_genesisOutpoint || res.prevPrevScript == t_selfScript, `can not backtrace to the genesis outpoint`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Back-to-genesis backtrace verification for a contract which can be backtraced to the genesis script.
|
|
42
|
+
* It will be a valid backtraceInfo if the prevPrevScript is the genesis script or the selfScript.
|
|
43
|
+
* @param backtraceInfo backtrace info to verify, including prevTx and prevPrevTx informations
|
|
44
|
+
* @param t_genesisScript expected genensis locking script which usually is a contract property and trustable
|
|
45
|
+
* @param t_selfScript expected self locking script, i.e. this.ctx.spentScript, of the current spending UTXO context and is trustable
|
|
46
|
+
* @param t_prevTxInputList input list of the prevTx which should be trustable
|
|
47
|
+
*/
|
|
48
|
+
static verifyFromScript(backtraceInfo, t_genesisScript, t_selfScript, t_prevTxInputList) {
|
|
49
|
+
const res = Backtrace.verifyChainTxs(backtraceInfo, t_prevTxInputList);
|
|
50
|
+
assert(res.prevPrevScript == t_genesisScript || res.prevPrevScript == t_selfScript, `can not backtrace to the genesis script`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Tx chain verification to ensure:
|
|
54
|
+
* 1. the current spending UTXO is the output of prevTx
|
|
55
|
+
* 2. the specific input of prevTx is the output of prevPrevTx
|
|
56
|
+
* @param backtraceInfo backtrace info to verify, including prevTx and prevPrevTx preimages
|
|
57
|
+
* @param t_prevTxInputList input list of the prevTx which should be trustable
|
|
58
|
+
* @returns locking script and outpoint of the specified output of prevPrevTx
|
|
59
|
+
*/
|
|
60
|
+
static verifyChainTxs(backtraceInfo, t_prevTxInputList) {
|
|
61
|
+
// check if the passed prevTxInput and prevTxInputIndexVal are matched
|
|
62
|
+
assert(slice(t_prevTxInputList, backtraceInfo.prevTxInputIndex * TX_INPUT_BYTE_LEN, (backtraceInfo.prevTxInputIndex + 1n) * TX_INPUT_BYTE_LEN) ==
|
|
63
|
+
TxUtils.mergeInput(backtraceInfo.prevTxInput));
|
|
64
|
+
// check if prevTxHash of passed prevTxInput and prevPrevTx are matched
|
|
65
|
+
const prevPrevTxHash = backtraceInfo.prevTxInput.prevTxHash;
|
|
66
|
+
assert(prevPrevTxHash ==
|
|
67
|
+
TxHashPreimageUtils.getTxHashFromTxHashPreimage(backtraceInfo.prevPrevTxPreimage));
|
|
68
|
+
// all fields in backtraceInfo have been verified
|
|
69
|
+
const prevPrevScript = slice(backtraceInfo.prevPrevTxPreimage.outputList, backtraceInfo.prevTxInput.prevOutputIndex * TX_OUTPUT_BYTE_LEN + TX_OUTPUT_SATOSHI_BYTE_LEN, (backtraceInfo.prevTxInput.prevOutputIndex) * TX_OUTPUT_BYTE_LEN + TX_OUTPUT_SATOSHI_BYTE_LEN + TX_OUTPUT_SCRIPT_HASH_LEN);
|
|
70
|
+
const prevPrevOutpoint = prevPrevTxHash + StdUtils.uint32ToByteString(backtraceInfo.prevTxInput.prevOutputIndex);
|
|
71
|
+
return { prevPrevScript, prevPrevOutpoint };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
__decorate([
|
|
75
|
+
method(),
|
|
76
|
+
__metadata("design:type", Function),
|
|
77
|
+
__metadata("design:paramtypes", [Object, String, BigInt]),
|
|
78
|
+
__metadata("design:returntype", void 0)
|
|
79
|
+
], Backtrace, "checkPrevTxHashPreimage", null);
|
|
80
|
+
__decorate([
|
|
81
|
+
method(),
|
|
82
|
+
__metadata("design:type", Function),
|
|
83
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
84
|
+
__metadata("design:returntype", void 0)
|
|
85
|
+
], Backtrace, "verifyFromOutpoint", null);
|
|
86
|
+
__decorate([
|
|
87
|
+
method(),
|
|
88
|
+
__metadata("design:type", Function),
|
|
89
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
90
|
+
__metadata("design:returntype", void 0)
|
|
91
|
+
], Backtrace, "verifyFromScript", null);
|
|
92
|
+
__decorate([
|
|
93
|
+
method(),
|
|
94
|
+
__metadata("design:type", Function),
|
|
95
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
96
|
+
__metadata("design:returntype", Object)
|
|
97
|
+
], Backtrace, "verifyChainTxs", null);
|
|
98
|
+
//# sourceMappingURL=backtrace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backtrace.js","sourceRoot":"","sources":["../../../../src/smart-contract/builtin-libs/backtrace.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,0BAA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AAc,CACnB,aAA4B,EAC5B,iBAA6B;QAE7B,sEAAsE;QACtE,MAAM,CACJ,KAAK,CACH,iBAAiB,EACjB,aAAa,CAAC,gBAAgB,GAAG,iBAAiB,EAClD,CAAC,aAAa,CAAC,gBAAgB,GAAG,EAAE,CAAC,GAAG,iBAAiB,CAC1D;YACD,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAC9C,CAAC;QACF,uEAAuE;QACvE,MAAM,cAAc,GAAG,aAAa,CAAC,WAAW,CAAC,UAAU,CAAC;QAC5D,MAAM,CACJ,cAAc;YACZ,mBAAmB,CAAC,2BAA2B,CAAC,aAAa,CAAC,kBAAkB,CAAC,CACpF,CAAC;QACF,iDAAiD;QACjD,MAAM,cAAc,GAClB,KAAK,CACH,aAAa,CAAC,kBAAkB,CAAC,UAAU,EAC3C,aAAa,CAAC,WAAW,CAAC,eAAe,GAAG,kBAAkB,GAAG,0BAA0B,EAC3F,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,kBAAkB,GAAG,0BAA0B,GAAG,yBAAyB,CAC1H,CAAC;QACJ,MAAM,gBAAgB,GACpB,cAAc,GAAG,QAAQ,CAAC,kBAAkB,CAAC,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;QAC1F,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;IAC9C,CAAC;CACF;AA3FQ;IADN,MAAM,EAAE;;;;8CAQR;AAUM;IADN,MAAM,EAAE;;;;yCAYR;AAWM;IADN,MAAM,EAAE;;;;uCAYR;AAWM;IADN,MAAM,EAAE;;;;qCA8BR"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { method, prop } from '../decorators.js';
|
|
11
|
+
import { assert, byteStringToInt, len, slice, toByteString } from '../fns/index.js';
|
|
12
|
+
import { SmartContractLib } from '../smartContractLib.js';
|
|
13
|
+
import { StdUtils } from './stdUtils.js';
|
|
14
|
+
/**
|
|
15
|
+
* A reader to parse a ByteString buffer
|
|
16
|
+
* @category Standard Contracts
|
|
17
|
+
*/
|
|
18
|
+
export class ByteStringReader extends SmartContractLib {
|
|
19
|
+
constructor(buf) {
|
|
20
|
+
super(buf);
|
|
21
|
+
this.buf = buf;
|
|
22
|
+
this.pos = 0n;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if all have been read
|
|
26
|
+
* @returns true if all have been read
|
|
27
|
+
*/
|
|
28
|
+
eof() {
|
|
29
|
+
return this.pos >= len(this.buf);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* read bytes which encoded with bitcoin [value-pushing words]{@link https://wiki.bitcoinsv.io/index.php/Opcodes_used_in_Bitcoin_Script}
|
|
33
|
+
* @returns true if all have been read
|
|
34
|
+
*/
|
|
35
|
+
readBytes() {
|
|
36
|
+
let l = 0n;
|
|
37
|
+
let buf = this.buf;
|
|
38
|
+
let ret = toByteString('');
|
|
39
|
+
let header = byteStringToInt(slice(this.buf, this.pos, this.pos + 1n));
|
|
40
|
+
this.pos++;
|
|
41
|
+
if (header < 0x4cn) {
|
|
42
|
+
l = header;
|
|
43
|
+
ret = slice(buf, this.pos, this.pos + l);
|
|
44
|
+
}
|
|
45
|
+
else if (header == 0x4cn) {
|
|
46
|
+
l = StdUtils.fromLEUnsigned(slice(buf, this.pos, this.pos + 1n));
|
|
47
|
+
this.pos += 1n;
|
|
48
|
+
ret = slice(this.buf, this.pos, this.pos + l);
|
|
49
|
+
}
|
|
50
|
+
else if (header == 0x4dn) {
|
|
51
|
+
l = StdUtils.fromLEUnsigned(slice(this.buf, this.pos, this.pos + 2n));
|
|
52
|
+
this.pos += 2n;
|
|
53
|
+
ret = slice(this.buf, this.pos, this.pos + l);
|
|
54
|
+
}
|
|
55
|
+
else if (header == 0x4en) {
|
|
56
|
+
l = StdUtils.fromLEUnsigned(slice(this.buf, this.pos, this.pos + 4n));
|
|
57
|
+
this.pos += 4n;
|
|
58
|
+
ret = slice(this.buf, this.pos, this.pos + l);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// shall not reach here
|
|
62
|
+
assert(false);
|
|
63
|
+
}
|
|
64
|
+
this.pos += l;
|
|
65
|
+
return ret;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* read a byte as boolean
|
|
69
|
+
* @returns true if the read byte not equal to '00'
|
|
70
|
+
*/
|
|
71
|
+
readBool() {
|
|
72
|
+
let buf = slice(this.buf, this.pos, this.pos + 1n);
|
|
73
|
+
this.pos++;
|
|
74
|
+
return toByteString('00') != buf;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* read bytes as `readBytes` and convert it to a number with `byteString2Int`
|
|
78
|
+
* @returns a number
|
|
79
|
+
*/
|
|
80
|
+
readVarint() {
|
|
81
|
+
let ret = toByteString('');
|
|
82
|
+
let header = slice(this.buf, this.pos, this.pos + 1n);
|
|
83
|
+
this.pos++;
|
|
84
|
+
if (header == toByteString('fd')) {
|
|
85
|
+
ret = slice(this.buf, this.pos, this.pos + 2n);
|
|
86
|
+
this.pos += 2n;
|
|
87
|
+
}
|
|
88
|
+
else if (header == toByteString('fe')) {
|
|
89
|
+
ret = slice(this.buf, this.pos, this.pos + 4n);
|
|
90
|
+
this.pos += 4n;
|
|
91
|
+
}
|
|
92
|
+
else if (header == toByteString('ff')) {
|
|
93
|
+
ret = slice(this.buf, this.pos, this.pos + 8n);
|
|
94
|
+
this.pos += 8n;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
ret = header;
|
|
98
|
+
}
|
|
99
|
+
return StdUtils.fromLEUnsigned(ret);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
__decorate([
|
|
103
|
+
prop(),
|
|
104
|
+
__metadata("design:type", String)
|
|
105
|
+
], ByteStringReader.prototype, "buf", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
prop(),
|
|
108
|
+
__metadata("design:type", BigInt)
|
|
109
|
+
], ByteStringReader.prototype, "pos", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
method(),
|
|
112
|
+
__metadata("design:type", Function),
|
|
113
|
+
__metadata("design:paramtypes", []),
|
|
114
|
+
__metadata("design:returntype", Boolean)
|
|
115
|
+
], ByteStringReader.prototype, "eof", null);
|
|
116
|
+
__decorate([
|
|
117
|
+
method(),
|
|
118
|
+
__metadata("design:type", Function),
|
|
119
|
+
__metadata("design:paramtypes", []),
|
|
120
|
+
__metadata("design:returntype", String)
|
|
121
|
+
], ByteStringReader.prototype, "readBytes", null);
|
|
122
|
+
__decorate([
|
|
123
|
+
method(),
|
|
124
|
+
__metadata("design:type", Function),
|
|
125
|
+
__metadata("design:paramtypes", []),
|
|
126
|
+
__metadata("design:returntype", Boolean)
|
|
127
|
+
], ByteStringReader.prototype, "readBool", null);
|
|
128
|
+
__decorate([
|
|
129
|
+
method(),
|
|
130
|
+
__metadata("design:type", Function),
|
|
131
|
+
__metadata("design:paramtypes", []),
|
|
132
|
+
__metadata("design:returntype", BigInt)
|
|
133
|
+
], ByteStringReader.prototype, "readVarint", null);
|
|
134
|
+
//# sourceMappingURL=byteStringReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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ACD,OAAO,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACJ;AAjGG;IADC,IAAI,EAAE;;6CACS;AAEhB;IADC,IAAI,EAAE;;6CACK;AAaZ;IADC,MAAM,EAAE;;;;2CAGR;AAOD;IADC,MAAM,EAAE;;;;iDAmCR;AAOD;IADC,MAAM,EAAE;;;;gDAKR;AAOD;IADC,MAAM,EAAE;;;;kDAqBR"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { method, prop } from '../decorators.js';
|
|
11
|
+
import { assert, len, toByteString } from '../fns/index.js';
|
|
12
|
+
import { SmartContractLib } from '../smartContractLib.js';
|
|
13
|
+
import { StdUtils } from './stdUtils.js';
|
|
14
|
+
/**
|
|
15
|
+
* A writer that serializes `ByteString`, `boolean`, `bigint`
|
|
16
|
+
* @category Standard Contracts
|
|
17
|
+
*/
|
|
18
|
+
export class ByteStringWriter extends SmartContractLib {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this.buf = toByteString('');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* serializes `ByteString` with `VarInt` encoding
|
|
25
|
+
* @param buf a `ByteString`
|
|
26
|
+
* @returns serialized `ByteString`
|
|
27
|
+
*/
|
|
28
|
+
writeBytes(buf) {
|
|
29
|
+
let n = len(buf);
|
|
30
|
+
let header = toByteString('');
|
|
31
|
+
if (n < 0x4c) {
|
|
32
|
+
header = StdUtils.toLEUnsigned(n, 1n);
|
|
33
|
+
}
|
|
34
|
+
else if (n < 0x100) {
|
|
35
|
+
header = toByteString('4c') + StdUtils.toLEUnsigned(n, 1n);
|
|
36
|
+
}
|
|
37
|
+
else if (n < 0x10000) {
|
|
38
|
+
header = toByteString('4d') + StdUtils.toLEUnsigned(n, 2n);
|
|
39
|
+
}
|
|
40
|
+
else if (n < 0x100000000) {
|
|
41
|
+
header = toByteString('4e') + StdUtils.toLEUnsigned(n, 4n);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// shall not reach here
|
|
45
|
+
assert(false);
|
|
46
|
+
}
|
|
47
|
+
this.buf += header + buf;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* serializes `boolean` with fixed 1 byte
|
|
51
|
+
* @param x a boolean
|
|
52
|
+
* @returns serialized `ByteString`
|
|
53
|
+
*/
|
|
54
|
+
writeBool(x) {
|
|
55
|
+
this.buf += x ? toByteString('01') : toByteString('00');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* serializes `bigint` with `VarInt` encoding
|
|
59
|
+
* @param x a boolean
|
|
60
|
+
* @returns serialized `ByteString`
|
|
61
|
+
*/
|
|
62
|
+
writeVarInt(x) {
|
|
63
|
+
assert(x >= 0n);
|
|
64
|
+
let size = 0n;
|
|
65
|
+
if (x < 0xfdn) {
|
|
66
|
+
size = 1n;
|
|
67
|
+
}
|
|
68
|
+
else if (x < 0x10000n) {
|
|
69
|
+
this.buf += toByteString('fd');
|
|
70
|
+
size = 2n;
|
|
71
|
+
}
|
|
72
|
+
else if (x < 0x100000000n) {
|
|
73
|
+
size = 4n;
|
|
74
|
+
this.buf += toByteString('fe');
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
size = 8n;
|
|
78
|
+
this.buf += toByteString('ff');
|
|
79
|
+
}
|
|
80
|
+
this.buf += StdUtils.toLEUnsigned(x, size);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
__decorate([
|
|
84
|
+
prop(),
|
|
85
|
+
__metadata("design:type", String)
|
|
86
|
+
], ByteStringWriter.prototype, "buf", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
method(),
|
|
89
|
+
__metadata("design:type", Function),
|
|
90
|
+
__metadata("design:paramtypes", [String]),
|
|
91
|
+
__metadata("design:returntype", void 0)
|
|
92
|
+
], ByteStringWriter.prototype, "writeBytes", null);
|
|
93
|
+
__decorate([
|
|
94
|
+
method(),
|
|
95
|
+
__metadata("design:type", Function),
|
|
96
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
97
|
+
__metadata("design:returntype", void 0)
|
|
98
|
+
], ByteStringWriter.prototype, "writeBool", null);
|
|
99
|
+
__decorate([
|
|
100
|
+
method(),
|
|
101
|
+
__metadata("design:type", Function),
|
|
102
|
+
__metadata("design:paramtypes", [BigInt]),
|
|
103
|
+
__metadata("design:returntype", void 0)
|
|
104
|
+
], ByteStringWriter.prototype, "writeVarInt", null);
|
|
105
|
+
//# sourceMappingURL=byteStringWriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"byteStringWriter.js","sourceRoot":"","sources":["../../../../src/smart-contract/builtin-libs/byteStringWriter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAoC,GAAG,EAAS,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,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CAAC,IAAI,EAAE,CAAC,CAAC;QAChB,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;YACZ,IAAI,GAAG,EAAE,CAAC;QACd,CAAC;aACI,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC;YACpB,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,GAAG,EAAE,CAAC;QACd,CAAC;aACI,IAAI,CAAC,GAAG,YAAY,EAAE,CAAC;YACxB,IAAI,GAAG,EAAE,CAAC;YACV,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;aACI,CAAC;YACF,IAAI,GAAG,EAAE,CAAC;YACV,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;CACJ;AAzEG;IADC,IAAI,EAAE;;6CACS;AAYhB;IADC,MAAM,EAAE;;;;kDAwBR;AAQD;IADC,MAAM,EAAE;;;;iDAGR;AAQD;IADC,MAAM,EAAE;;;;mDAoBR"}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { prop, method } from '../decorators.js';
|
|
11
|
+
import { assert } from '../fns/assert.js';
|
|
12
|
+
import { byteStringToInt, intToByteString, len, reverseByteString, slice, toByteString } from '../fns/byteString.js';
|
|
13
|
+
import { hash256 } from '../fns/hashes.js';
|
|
14
|
+
import { SmartContractLib } from '../smartContractLib.js';
|
|
15
|
+
import { PubKey, Sig, PrivKey, SigHashPreimage } from '../types/primitives.js';
|
|
16
|
+
import { StdUtils } from './stdUtils.js';
|
|
17
|
+
import { TxUtils } from './txUtils.js';
|
|
18
|
+
/**
|
|
19
|
+
* Library for verifying preimage.
|
|
20
|
+
* @category Library
|
|
21
|
+
* @onchain
|
|
22
|
+
*/
|
|
23
|
+
export class ContextUtils extends SmartContractLib {
|
|
24
|
+
static normalize(k, modulus) {
|
|
25
|
+
const res = k % modulus;
|
|
26
|
+
// ensure it's positive
|
|
27
|
+
return (res < 0) ? res + modulus : res;
|
|
28
|
+
}
|
|
29
|
+
static sign(h, privKey, inverseK, r, rBigEndian, sigHashType) {
|
|
30
|
+
// TODO: r * privKey can also be precomputed
|
|
31
|
+
let s = inverseK * (h + r * privKey);
|
|
32
|
+
const N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
|
|
33
|
+
s = ContextUtils.normalize(s, N);
|
|
34
|
+
// lower S
|
|
35
|
+
if (s > N / 2n) {
|
|
36
|
+
s = N - s;
|
|
37
|
+
}
|
|
38
|
+
// require(s != 0); // check offchain
|
|
39
|
+
/*
|
|
40
|
+
* DER: h + l + rh + rl + r + sh + sl + s + hashtype
|
|
41
|
+
* note: r & s are at most 33 bytes, thus no need to convert endian of rl & sl
|
|
42
|
+
*/
|
|
43
|
+
const rlen = BigInt(len(rBigEndian));
|
|
44
|
+
const slen = len(intToByteString(s));
|
|
45
|
+
// we convert s to 32 bytes, otherwise reverseByteString(, 32) fails when s is strictly less than 31 bytes (note: 31 bytes works)
|
|
46
|
+
// slice it after reversing to remove extra leading zeros, otherwise strict DER rule fails it due to not minimally encoded
|
|
47
|
+
const sBigEndian = slice(reverseByteString(intToByteString(s, 32n), BigInt(32)), 32n - slen);
|
|
48
|
+
const l = 4n + rlen + BigInt(slen);
|
|
49
|
+
// rBigEndian must be mininally encoded, to conform to strict DER rule
|
|
50
|
+
const rb = toByteString('30')
|
|
51
|
+
+ intToByteString(l)
|
|
52
|
+
+ toByteString('02')
|
|
53
|
+
+ intToByteString(rlen)
|
|
54
|
+
+ rBigEndian
|
|
55
|
+
+ toByteString('02')
|
|
56
|
+
+ intToByteString(slen)
|
|
57
|
+
+ sBigEndian
|
|
58
|
+
+ toByteString(sigHashType);
|
|
59
|
+
return Sig(rb);
|
|
60
|
+
}
|
|
61
|
+
static fromBEUnsigned(b) {
|
|
62
|
+
// change endian first
|
|
63
|
+
// append positive sign byte. This does not hurt even when sign bit is already positive
|
|
64
|
+
return byteStringToInt(reverseByteString(b, 32n) + toByteString('00'));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* sign the transaction preimage
|
|
68
|
+
* @param shPreimage - the transaction preimage
|
|
69
|
+
* @returns a signature
|
|
70
|
+
*/
|
|
71
|
+
static checkSHPreimage(shPreimage, sigHashType) {
|
|
72
|
+
assert(len(shPreimage.nVersion) == 4n, 'invalid length of nVersion');
|
|
73
|
+
assert(len(shPreimage.hashPrevouts) == 32n, 'invalid length of hashPrevouts');
|
|
74
|
+
assert(len(shPreimage.spentScriptHash) == 32n, 'invalid length of spentScriptHash');
|
|
75
|
+
assert(len(shPreimage.spentDataHash) == 32n, 'invalid length of spentDataHash');
|
|
76
|
+
assert(shPreimage.value >= 0n, 'invalid value of value');
|
|
77
|
+
assert(len(shPreimage.nSequence) == 4n, 'invalid length of nSequence');
|
|
78
|
+
assert(len(shPreimage.hashSpentAmounts) == 32n, 'invalid length of hashSpentAmounts');
|
|
79
|
+
assert(len(shPreimage.hashSpentScriptHashes) == 32n, 'invalid length of hashSpentScriptHashes');
|
|
80
|
+
assert(len(shPreimage.hashSpentDataHashes) == 32n, 'invalid length of hashSpentDataHashes');
|
|
81
|
+
assert(len(shPreimage.hashSequences) == 32n, 'invalid length of hashSequences');
|
|
82
|
+
assert(len(shPreimage.hashOutputs) == 32n, 'invalid length of hashOutputs');
|
|
83
|
+
assert(shPreimage.inputIndex >= 0n, 'invalid value of inputIndex');
|
|
84
|
+
assert(shPreimage.nLockTime >= 0n, 'invalid value of nLockTime');
|
|
85
|
+
assert(shPreimage.sigHashType == 1n
|
|
86
|
+
|| shPreimage.sigHashType == 2n
|
|
87
|
+
|| shPreimage.sigHashType == 3n
|
|
88
|
+
|| shPreimage.sigHashType == 0x81n
|
|
89
|
+
|| shPreimage.sigHashType == 0x82n
|
|
90
|
+
|| shPreimage.sigHashType == 0x83n, 'invalid value of sigHashType');
|
|
91
|
+
const preimage = shPreimage.nVersion
|
|
92
|
+
+ shPreimage.hashPrevouts
|
|
93
|
+
+ shPreimage.spentScriptHash
|
|
94
|
+
+ shPreimage.spentDataHash
|
|
95
|
+
+ TxUtils.satoshisToByteString(shPreimage.value)
|
|
96
|
+
+ shPreimage.nSequence
|
|
97
|
+
+ shPreimage.hashSpentAmounts
|
|
98
|
+
+ shPreimage.hashSpentScriptHashes
|
|
99
|
+
+ shPreimage.hashSpentDataHashes
|
|
100
|
+
+ shPreimage.hashSequences
|
|
101
|
+
+ shPreimage.hashOutputs
|
|
102
|
+
+ StdUtils.toLEUnsigned(shPreimage.inputIndex, 4n)
|
|
103
|
+
+ StdUtils.toLEUnsigned(shPreimage.nLockTime, 4n)
|
|
104
|
+
+ intToByteString(shPreimage.sigHashType, 4n);
|
|
105
|
+
const h = hash256(preimage);
|
|
106
|
+
const sig = ContextUtils.sign(ContextUtils.fromBEUnsigned(h), ContextUtils.privKey, ContextUtils.invK, ContextUtils.r, ContextUtils.rBigEndian, sigHashType);
|
|
107
|
+
return sig;
|
|
108
|
+
}
|
|
109
|
+
static serializeSHPreimage(shPreimage) {
|
|
110
|
+
assert(len(shPreimage.nVersion) == 4n, 'invalid length of nVersion');
|
|
111
|
+
assert(len(shPreimage.hashPrevouts) == 32n, 'invalid length of hashPrevouts');
|
|
112
|
+
assert(len(shPreimage.spentScriptHash) == 32n, 'invalid length of spentScriptHash');
|
|
113
|
+
assert(len(shPreimage.spentDataHash) == 32n, 'invalid length of spentDataHash');
|
|
114
|
+
assert(shPreimage.value >= 0n, 'invalid value of value');
|
|
115
|
+
assert(len(shPreimage.nSequence) == 4n, 'invalid length of nSequence');
|
|
116
|
+
assert(len(shPreimage.hashSpentAmounts) == 32n, 'invalid length of hashSpentAmounts');
|
|
117
|
+
assert(len(shPreimage.hashSpentScriptHashes) == 32n, 'invalid length of hashSpentScriptHashes');
|
|
118
|
+
assert(len(shPreimage.hashSpentDataHashes) == 32n, 'invalid length of hashSpentDataHashes');
|
|
119
|
+
assert(len(shPreimage.hashSequences) == 32n, 'invalid length of hashSequences');
|
|
120
|
+
assert(len(shPreimage.hashOutputs) == 32n, 'invalid length of hashOutputs');
|
|
121
|
+
assert(shPreimage.inputIndex >= 0n, 'invalid value of inputIndex');
|
|
122
|
+
assert(shPreimage.nLockTime >= 0n, 'invalid value of nLockTime');
|
|
123
|
+
assert(shPreimage.sigHashType == 1n
|
|
124
|
+
|| shPreimage.sigHashType == 2n
|
|
125
|
+
|| shPreimage.sigHashType == 3n
|
|
126
|
+
|| shPreimage.sigHashType == 0x81n
|
|
127
|
+
|| shPreimage.sigHashType == 0x82n
|
|
128
|
+
|| shPreimage.sigHashType == 0x83n, 'invalid value of sigHashType');
|
|
129
|
+
const preimage = shPreimage.nVersion
|
|
130
|
+
+ shPreimage.hashPrevouts
|
|
131
|
+
+ shPreimage.spentScriptHash
|
|
132
|
+
+ shPreimage.spentDataHash
|
|
133
|
+
+ TxUtils.satoshisToByteString(shPreimage.value)
|
|
134
|
+
+ shPreimage.nSequence
|
|
135
|
+
+ shPreimage.hashSpentAmounts
|
|
136
|
+
+ shPreimage.hashSpentScriptHashes
|
|
137
|
+
+ shPreimage.hashSpentDataHashes
|
|
138
|
+
+ shPreimage.hashSequences
|
|
139
|
+
+ shPreimage.hashOutputs
|
|
140
|
+
+ StdUtils.toLEUnsigned(shPreimage.inputIndex, 4n)
|
|
141
|
+
+ StdUtils.toLEUnsigned(shPreimage.nLockTime, 4n)
|
|
142
|
+
+ intToByteString(shPreimage.sigHashType, 4n);
|
|
143
|
+
return SigHashPreimage(preimage);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Verify that the prevouts context passed in by the user is authentic
|
|
147
|
+
* @param prevouts prevouts context passed in by the user that need to be verified
|
|
148
|
+
* @param prevout prevout context passed in by the user that need to be verified
|
|
149
|
+
* @param t_hashPrevouts hashPrevouts in preimage which is trustable
|
|
150
|
+
* @param t_inputIndex the index of the input, which is trustable
|
|
151
|
+
* @returns the number of inputs, which is trustable
|
|
152
|
+
*/
|
|
153
|
+
static checkPrevouts(prevouts, t_hashPrevouts, t_inputIndex, t_inputCount) {
|
|
154
|
+
// check prevouts
|
|
155
|
+
assert(hash256(prevouts) == t_hashPrevouts, 'hashPrevouts mismatch');
|
|
156
|
+
assert(t_inputIndex < t_inputCount, 'invalid prevouts');
|
|
157
|
+
assert(t_inputCount == StdUtils.checkLenDivisibleBy(prevouts, 36n), 'invalid prevouts');
|
|
158
|
+
const b = slice(prevouts, t_inputIndex * 36n, (t_inputIndex + 1n) * 36n);
|
|
159
|
+
return {
|
|
160
|
+
txHash: slice(b, 0n, 32n),
|
|
161
|
+
outputIndex: StdUtils.byteStringToUInt32(slice(b, 32n, 36n)),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Check if the spent scripts array passed in matches the shaSpentScripts
|
|
166
|
+
* @param spentScriptHashes array of spent scripts passed in that need to be verified
|
|
167
|
+
* @param t_hashSpentScripts the hash of the merged spent scripts, which comes from preimage and is trustable
|
|
168
|
+
* @param t_inputCount must be trustable, the number of inputs
|
|
169
|
+
*/
|
|
170
|
+
static checkSpentScripts(spentScriptHashes, t_hashSpentScripts, t_inputCount) {
|
|
171
|
+
assert(hash256(spentScriptHashes) == t_hashSpentScripts, 'hashSpentScripts mismatch');
|
|
172
|
+
assert(t_inputCount == StdUtils.checkLenDivisibleBy(spentScriptHashes, 32n), 'invalid spentScriptHashes');
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Check if the spent amounts array passed in matches the shaSpentAmounts
|
|
176
|
+
* @param spentAmounts array of spent amounts passed in that need to be verified
|
|
177
|
+
* @param t_hashSpentAmounts the hash of the merged spent amounts, which comes from preimage and is trustable
|
|
178
|
+
* @param t_inputCount must be trustable, the number of inputs
|
|
179
|
+
*/
|
|
180
|
+
static checkSpentAmounts(spentAmounts, t_hashSpentAmounts) {
|
|
181
|
+
assert(hash256(spentAmounts) == t_hashSpentAmounts, 'hashSpentAmounts mismatch');
|
|
182
|
+
return StdUtils.checkLenDivisibleBy(spentAmounts, 8n);
|
|
183
|
+
}
|
|
184
|
+
static checkSpentDataHashes(spentDataHashes, t_hashSpentDataHashes, t_inputCount) {
|
|
185
|
+
assert(hash256(spentDataHashes) == t_hashSpentDataHashes, 'hashSpentDataHashes mismatch');
|
|
186
|
+
assert(t_inputCount == StdUtils.checkLenDivisibleBy(spentDataHashes, 32n), 'invalid spentDataHashes');
|
|
187
|
+
}
|
|
188
|
+
static getSpentScriptHash(spentScriptHashes, inputIndex) {
|
|
189
|
+
return slice(spentScriptHashes, inputIndex * 32n, (inputIndex + 1n) * 32n);
|
|
190
|
+
}
|
|
191
|
+
static getSpentAmount(spentAmounts, inputIndex) {
|
|
192
|
+
return StdUtils.fromLEUnsigned(slice(spentAmounts, inputIndex * 8n, (inputIndex + 1n) * 8n));
|
|
193
|
+
}
|
|
194
|
+
static getSpentDataHash(spentDataHashes, inputIndex) {
|
|
195
|
+
return slice(spentDataHashes, inputIndex * 32n, (inputIndex + 1n) * 32n);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// The following arguments can be generated using sample code at
|
|
199
|
+
// https://gist.github.com/scrypt-sv/f6882be580780a88984cee75dd1564c4.js
|
|
200
|
+
ContextUtils.privKey = PrivKey(0x26f00fe2340a84335ebdf30f57e9bb58487117b29355718f5e46bf5168d7df97n);
|
|
201
|
+
ContextUtils.pubKey = PubKey(toByteString('02ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382'));
|
|
202
|
+
// invK is the modular inverse of k, the ephemeral key
|
|
203
|
+
ContextUtils.invK = 0xc8ffdbaa05d93aa4ede79ec58f06a72562048b775a3507c2bf44bde4f007c40an;
|
|
204
|
+
// r is x coordinate of R, which is kG
|
|
205
|
+
ContextUtils.r = 0x1008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266cn;
|
|
206
|
+
// rBigEndian is the signed magnitude representation of r, in big endian
|
|
207
|
+
ContextUtils.rBigEndian = toByteString('1008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c');
|
|
208
|
+
__decorate([
|
|
209
|
+
prop(),
|
|
210
|
+
__metadata("design:type", BigInt)
|
|
211
|
+
], ContextUtils, "privKey", void 0);
|
|
212
|
+
__decorate([
|
|
213
|
+
prop(),
|
|
214
|
+
__metadata("design:type", String)
|
|
215
|
+
], ContextUtils, "pubKey", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
prop(),
|
|
218
|
+
__metadata("design:type", BigInt)
|
|
219
|
+
], ContextUtils, "invK", void 0);
|
|
220
|
+
__decorate([
|
|
221
|
+
prop(),
|
|
222
|
+
__metadata("design:type", BigInt)
|
|
223
|
+
], ContextUtils, "r", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
prop(),
|
|
226
|
+
__metadata("design:type", String)
|
|
227
|
+
], ContextUtils, "rBigEndian", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
method(),
|
|
230
|
+
__metadata("design:type", Function),
|
|
231
|
+
__metadata("design:paramtypes", [BigInt, BigInt]),
|
|
232
|
+
__metadata("design:returntype", BigInt)
|
|
233
|
+
], ContextUtils, "normalize", null);
|
|
234
|
+
__decorate([
|
|
235
|
+
method(),
|
|
236
|
+
__metadata("design:type", Function),
|
|
237
|
+
__metadata("design:paramtypes", [BigInt, BigInt, BigInt, BigInt, String, String]),
|
|
238
|
+
__metadata("design:returntype", String)
|
|
239
|
+
], ContextUtils, "sign", null);
|
|
240
|
+
__decorate([
|
|
241
|
+
method(),
|
|
242
|
+
__metadata("design:type", Function),
|
|
243
|
+
__metadata("design:paramtypes", [String]),
|
|
244
|
+
__metadata("design:returntype", BigInt)
|
|
245
|
+
], ContextUtils, "fromBEUnsigned", null);
|
|
246
|
+
__decorate([
|
|
247
|
+
method(),
|
|
248
|
+
__metadata("design:type", Function),
|
|
249
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
250
|
+
__metadata("design:returntype", String)
|
|
251
|
+
], ContextUtils, "checkSHPreimage", null);
|
|
252
|
+
__decorate([
|
|
253
|
+
method(),
|
|
254
|
+
__metadata("design:type", Function),
|
|
255
|
+
__metadata("design:paramtypes", [Object]),
|
|
256
|
+
__metadata("design:returntype", String)
|
|
257
|
+
], ContextUtils, "serializeSHPreimage", null);
|
|
258
|
+
__decorate([
|
|
259
|
+
method(),
|
|
260
|
+
__metadata("design:type", Function),
|
|
261
|
+
__metadata("design:paramtypes", [String, String, BigInt, BigInt]),
|
|
262
|
+
__metadata("design:returntype", Object)
|
|
263
|
+
], ContextUtils, "checkPrevouts", null);
|
|
264
|
+
__decorate([
|
|
265
|
+
method(),
|
|
266
|
+
__metadata("design:type", Function),
|
|
267
|
+
__metadata("design:paramtypes", [String, String, BigInt]),
|
|
268
|
+
__metadata("design:returntype", void 0)
|
|
269
|
+
], ContextUtils, "checkSpentScripts", null);
|
|
270
|
+
__decorate([
|
|
271
|
+
method(),
|
|
272
|
+
__metadata("design:type", Function),
|
|
273
|
+
__metadata("design:paramtypes", [String, String]),
|
|
274
|
+
__metadata("design:returntype", BigInt)
|
|
275
|
+
], ContextUtils, "checkSpentAmounts", null);
|
|
276
|
+
__decorate([
|
|
277
|
+
method(),
|
|
278
|
+
__metadata("design:type", Function),
|
|
279
|
+
__metadata("design:paramtypes", [String, String, BigInt]),
|
|
280
|
+
__metadata("design:returntype", void 0)
|
|
281
|
+
], ContextUtils, "checkSpentDataHashes", null);
|
|
282
|
+
__decorate([
|
|
283
|
+
method(),
|
|
284
|
+
__metadata("design:type", Function),
|
|
285
|
+
__metadata("design:paramtypes", [String, BigInt]),
|
|
286
|
+
__metadata("design:returntype", String)
|
|
287
|
+
], ContextUtils, "getSpentScriptHash", null);
|
|
288
|
+
__decorate([
|
|
289
|
+
method(),
|
|
290
|
+
__metadata("design:type", Function),
|
|
291
|
+
__metadata("design:paramtypes", [String, BigInt]),
|
|
292
|
+
__metadata("design:returntype", BigInt)
|
|
293
|
+
], ContextUtils, "getSpentAmount", null);
|
|
294
|
+
__decorate([
|
|
295
|
+
method(),
|
|
296
|
+
__metadata("design:type", Function),
|
|
297
|
+
__metadata("design:paramtypes", [String, BigInt]),
|
|
298
|
+
__metadata("design:returntype", String)
|
|
299
|
+
], ContextUtils, "getSpentDataHash", null);
|
|
300
|
+
//# sourceMappingURL=contextUtils.js.map
|