@opcat-labs/scrypt-ts-opcat 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -0
- package/assets/.templates/smart-contract/builtin-libs/TxHashPreimageUtils.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/backtrace.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/byteStringReader.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/byteStringWriter.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.tpl +11 -21
- package/assets/.templates/smart-contract/builtin-libs/p2pk.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/p2pkh.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/stateLib.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/stateUtils.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/stateUtils.scrypt.tpl +2 -2
- package/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.tpl +10 -5
- package/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.map +1 -1
- package/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.tpl +7 -3
- package/assets/smart-contract/builtin-libs/TxHashPreimageUtils.scrypt +7 -7
- package/assets/smart-contract/builtin-libs/backtrace.scrypt +12 -12
- package/assets/smart-contract/builtin-libs/byteStringReader.scrypt +5 -5
- package/assets/smart-contract/builtin-libs/byteStringWriter.scrypt +6 -6
- package/assets/smart-contract/builtin-libs/contextUtils.scrypt +23 -33
- package/assets/smart-contract/builtin-libs/p2pk.scrypt +1 -1
- package/assets/smart-contract/builtin-libs/p2pkh.scrypt +1 -1
- package/assets/smart-contract/builtin-libs/stateLib.scrypt +1 -1
- package/assets/smart-contract/builtin-libs/stateUtils.scrypt +3 -3
- package/assets/smart-contract/builtin-libs/stdUtils.scrypt +21 -16
- package/assets/smart-contract/builtin-libs/txUtils.scrypt +16 -12
- package/assets/smart-contract/types/structs.scrypt +8 -8
- package/dist/cjs/features/call.cjs +34 -16
- package/dist/cjs/features/call.js.map +1 -1
- package/dist/cjs/features/deploy.cjs +22 -8
- package/dist/cjs/features/deploy.js.map +1 -1
- package/dist/cjs/features/deployGenesis.cjs +59 -0
- package/dist/cjs/features/deployGenesis.js.map +1 -0
- package/dist/cjs/features/index.cjs +3 -1
- package/dist/cjs/features/index.js.map +1 -1
- package/dist/cjs/index.cjs +42 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/networks.cjs +7 -30
- package/dist/cjs/networks.js.map +1 -1
- package/dist/cjs/providers/dummyProvider.cjs +21 -4
- package/dist/cjs/providers/dummyProvider.js.map +1 -1
- package/dist/cjs/providers/rpcProvider.cjs +1 -1
- package/dist/cjs/providers/utxoProvider.cjs +5 -1
- package/dist/cjs/providers/utxoProvider.js.map +1 -1
- package/dist/cjs/psbt/bufferutils.cjs +7 -2
- package/dist/cjs/psbt/bufferutils.js.map +1 -1
- package/dist/cjs/psbt/extPsbt.cjs +371 -60
- package/dist/cjs/psbt/extPsbt.js.map +1 -1
- package/dist/cjs/psbt/psbt.cjs +18 -22
- package/dist/cjs/psbt/psbt.js.map +1 -1
- package/dist/cjs/psbt/psbtutils.cjs +4 -7
- package/dist/cjs/psbt/psbtutils.js.map +1 -1
- package/dist/cjs/psbt/signatureutils.cjs +3 -8
- package/dist/cjs/psbt/signatureutils.js.map +1 -1
- package/dist/cjs/signers/defaultSigner.cjs +29 -3
- package/dist/cjs/signers/defaultSigner.js.map +1 -1
- package/dist/cjs/signers/unisatSigner.cjs +27 -1
- package/dist/cjs/signers/unisatSigner.js.map +1 -1
- package/dist/cjs/smart-contract/abi.cjs +123 -3
- package/dist/cjs/smart-contract/abi.js.map +1 -1
- package/dist/cjs/smart-contract/abstractContract.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/backtrace.cjs +9 -0
- package/dist/cjs/smart-contract/builtin-libs/backtrace.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/byteStringReader.cjs +4 -4
- package/dist/cjs/smart-contract/builtin-libs/byteStringReader.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/byteStringWriter.cjs +1 -1
- package/dist/cjs/smart-contract/builtin-libs/byteStringWriter.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/contextUtils.cjs +100 -45
- package/dist/cjs/smart-contract/builtin-libs/contextUtils.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/p2pk.cjs +9 -0
- package/dist/cjs/smart-contract/builtin-libs/p2pk.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/p2pkh.cjs +10 -0
- package/dist/cjs/smart-contract/builtin-libs/p2pkh.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/stateLib.cjs +22 -8
- package/dist/cjs/smart-contract/builtin-libs/stateLib.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/stateUtils.cjs +7 -4
- package/dist/cjs/smart-contract/builtin-libs/stateUtils.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/stdUtils.cjs +75 -19
- package/dist/cjs/smart-contract/builtin-libs/stdUtils.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/txHashPreimageUtils.cjs +27 -0
- package/dist/cjs/smart-contract/builtin-libs/txHashPreimageUtils.js.map +1 -1
- package/dist/cjs/smart-contract/builtin-libs/txUtils.cjs +23 -8
- package/dist/cjs/smart-contract/builtin-libs/txUtils.js.map +1 -1
- package/dist/cjs/smart-contract/consts.cjs +1 -11
- package/dist/cjs/smart-contract/consts.js.map +1 -1
- package/dist/cjs/smart-contract/deserializer.cjs +163 -0
- package/dist/cjs/smart-contract/deserializer.js.map +1 -0
- package/dist/cjs/smart-contract/fns/assert.cjs +1 -1
- package/dist/cjs/smart-contract/fns/bitwise.cjs +5 -5
- package/dist/cjs/smart-contract/fns/bitwise.js.map +1 -1
- package/dist/cjs/smart-contract/fns/byteString.cjs +8 -5
- package/dist/cjs/smart-contract/fns/byteString.js.map +1 -1
- package/dist/cjs/smart-contract/fns/equals.cjs +1 -1
- package/dist/cjs/smart-contract/fns/exit.cjs +16 -0
- package/dist/cjs/smart-contract/fns/exit.js.map +1 -0
- package/dist/cjs/smart-contract/fns/fill.cjs +1 -1
- package/dist/cjs/smart-contract/fns/index.cjs +3 -1
- package/dist/cjs/smart-contract/fns/index.js.map +1 -1
- package/dist/cjs/smart-contract/fns/math.cjs +4 -4
- package/dist/cjs/smart-contract/methods/backtraceToGenensis.cjs +12 -8
- package/dist/cjs/smart-contract/methods/backtraceToGenensis.js.map +1 -1
- package/dist/cjs/smart-contract/methods/checkCtx.cjs +10 -9
- package/dist/cjs/smart-contract/methods/checkCtx.js.map +1 -1
- package/dist/cjs/smart-contract/methods/checkInputState.cjs +1 -0
- package/dist/cjs/smart-contract/methods/checkInputState.js.map +1 -1
- package/dist/cjs/smart-contract/methods/checkInputStateHashes.cjs +3 -2
- package/dist/cjs/smart-contract/methods/checkInputStateHashes.js.map +1 -1
- package/dist/cjs/smart-contract/methods/checkSHPreimage.cjs +4 -3
- package/dist/cjs/smart-contract/methods/checkSHPreimage.js.map +1 -1
- package/dist/cjs/smart-contract/methods/checkSig.cjs +76 -12
- package/dist/cjs/smart-contract/methods/checkSig.js.map +1 -1
- package/dist/cjs/smart-contract/serializer.cjs +3 -30
- package/dist/cjs/smart-contract/serializer.js.map +1 -1
- package/dist/cjs/smart-contract/smartContract.cjs +77 -104
- package/dist/cjs/smart-contract/smartContract.js.map +1 -1
- package/dist/cjs/smart-contract/smartContractLib.cjs +5 -0
- package/dist/cjs/smart-contract/smartContractLib.js.map +1 -1
- package/dist/cjs/smart-contract/stateSerializer.cjs +21 -4
- package/dist/cjs/smart-contract/stateSerializer.js.map +1 -1
- package/dist/cjs/smart-contract/types/abi.js.map +1 -1
- package/dist/cjs/smart-contract/types/artifact.cjs +5 -1
- package/dist/cjs/smart-contract/types/artifact.js.map +1 -1
- package/dist/cjs/smart-contract/types/bn.cjs +18 -0
- package/dist/cjs/smart-contract/types/bn.js.map +1 -1
- package/dist/cjs/smart-contract/types/index.cjs +2 -1
- package/dist/cjs/smart-contract/types/index.js.map +1 -1
- package/dist/cjs/smart-contract/types/opCode.cjs +1 -1
- package/dist/cjs/smart-contract/types/primitives.cjs +17 -9
- package/dist/cjs/smart-contract/types/primitives.js.map +1 -1
- package/dist/cjs/utils/checkIntegrity.cjs +2 -2
- package/dist/cjs/utils/common.cjs +11 -39
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/cjs/utils/constants.cjs +3 -0
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/cjs/utils/index.cjs +4 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/proof.cjs +15 -42
- package/dist/cjs/utils/proof.js.map +1 -1
- package/dist/esm/features/call.js +34 -16
- package/dist/esm/features/call.js.map +1 -1
- package/dist/esm/features/deploy.js +22 -8
- package/dist/esm/features/deploy.js.map +1 -1
- package/dist/esm/features/deployGenesis.js +55 -0
- package/dist/esm/features/deployGenesis.js.map +1 -0
- package/dist/esm/features/index.js +1 -0
- package/dist/esm/features/index.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/networks.js +7 -7
- package/dist/esm/networks.js.map +1 -1
- package/dist/esm/providers/dummyProvider.js +21 -4
- package/dist/esm/providers/dummyProvider.js.map +1 -1
- package/dist/esm/providers/rpcProvider.js +1 -1
- package/dist/esm/providers/utxoProvider.js +5 -1
- package/dist/esm/providers/utxoProvider.js.map +1 -1
- package/dist/esm/psbt/bufferutils.js +7 -2
- package/dist/esm/psbt/bufferutils.js.map +1 -1
- package/dist/esm/psbt/extPsbt.js +373 -62
- package/dist/esm/psbt/extPsbt.js.map +1 -1
- package/dist/esm/psbt/psbt.js +10 -14
- package/dist/esm/psbt/psbt.js.map +1 -1
- package/dist/esm/psbt/psbtutils.js +4 -7
- package/dist/esm/psbt/psbtutils.js.map +1 -1
- package/dist/esm/psbt/signatureutils.js +2 -9
- package/dist/esm/psbt/signatureutils.js.map +1 -1
- package/dist/esm/signers/defaultSigner.js +30 -4
- package/dist/esm/signers/defaultSigner.js.map +1 -1
- package/dist/esm/signers/unisatSigner.js +27 -1
- package/dist/esm/signers/unisatSigner.js.map +1 -1
- package/dist/esm/smart-contract/abi.js +124 -4
- package/dist/esm/smart-contract/abi.js.map +1 -1
- package/dist/esm/smart-contract/abstractContract.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/backtrace.js +9 -0
- package/dist/esm/smart-contract/builtin-libs/backtrace.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/byteStringReader.js +4 -4
- package/dist/esm/smart-contract/builtin-libs/byteStringReader.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/byteStringWriter.js +1 -1
- package/dist/esm/smart-contract/builtin-libs/byteStringWriter.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/contextUtils.js +100 -45
- package/dist/esm/smart-contract/builtin-libs/contextUtils.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/p2pk.js +9 -0
- package/dist/esm/smart-contract/builtin-libs/p2pk.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/p2pkh.js +10 -0
- package/dist/esm/smart-contract/builtin-libs/p2pkh.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/stateLib.js +22 -8
- package/dist/esm/smart-contract/builtin-libs/stateLib.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/stateUtils.js +7 -4
- package/dist/esm/smart-contract/builtin-libs/stateUtils.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/stdUtils.js +75 -19
- package/dist/esm/smart-contract/builtin-libs/stdUtils.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/txHashPreimageUtils.js +27 -0
- package/dist/esm/smart-contract/builtin-libs/txHashPreimageUtils.js.map +1 -1
- package/dist/esm/smart-contract/builtin-libs/txUtils.js +23 -8
- package/dist/esm/smart-contract/builtin-libs/txUtils.js.map +1 -1
- package/dist/esm/smart-contract/consts.js +0 -10
- package/dist/esm/smart-contract/consts.js.map +1 -1
- package/dist/esm/smart-contract/deserializer.js +156 -0
- package/dist/esm/smart-contract/deserializer.js.map +1 -0
- package/dist/esm/smart-contract/fns/assert.js +1 -1
- package/dist/esm/smart-contract/fns/bitwise.js +5 -5
- package/dist/esm/smart-contract/fns/bitwise.js.map +1 -1
- package/dist/esm/smart-contract/fns/byteString.js +8 -5
- package/dist/esm/smart-contract/fns/byteString.js.map +1 -1
- package/dist/esm/smart-contract/fns/equals.js +1 -1
- package/dist/esm/smart-contract/fns/exit.js +12 -0
- package/dist/esm/smart-contract/fns/exit.js.map +1 -0
- package/dist/esm/smart-contract/fns/fill.js +1 -1
- package/dist/esm/smart-contract/fns/index.js +1 -0
- package/dist/esm/smart-contract/fns/index.js.map +1 -1
- package/dist/esm/smart-contract/fns/math.js +4 -4
- package/dist/esm/smart-contract/methods/backtraceToGenensis.js +12 -8
- package/dist/esm/smart-contract/methods/backtraceToGenensis.js.map +1 -1
- package/dist/esm/smart-contract/methods/checkCtx.js +10 -9
- package/dist/esm/smart-contract/methods/checkCtx.js.map +1 -1
- package/dist/esm/smart-contract/methods/checkInputState.js +1 -0
- package/dist/esm/smart-contract/methods/checkInputState.js.map +1 -1
- package/dist/esm/smart-contract/methods/checkInputStateHashes.js +3 -2
- package/dist/esm/smart-contract/methods/checkInputStateHashes.js.map +1 -1
- package/dist/esm/smart-contract/methods/checkSHPreimage.js +4 -3
- package/dist/esm/smart-contract/methods/checkSHPreimage.js.map +1 -1
- package/dist/esm/smart-contract/methods/checkSig.js +74 -11
- package/dist/esm/smart-contract/methods/checkSig.js.map +1 -1
- package/dist/esm/smart-contract/serializer.js +5 -27
- package/dist/esm/smart-contract/serializer.js.map +1 -1
- package/dist/esm/smart-contract/smartContract.js +79 -106
- package/dist/esm/smart-contract/smartContract.js.map +1 -1
- package/dist/esm/smart-contract/smartContractLib.js +5 -0
- package/dist/esm/smart-contract/smartContractLib.js.map +1 -1
- package/dist/esm/smart-contract/stateSerializer.js +22 -5
- package/dist/esm/smart-contract/stateSerializer.js.map +1 -1
- package/dist/esm/smart-contract/types/abi.js.map +1 -1
- package/dist/esm/smart-contract/types/artifact.js +5 -1
- package/dist/esm/smart-contract/types/artifact.js.map +1 -1
- package/dist/esm/smart-contract/types/bn.js +18 -0
- package/dist/esm/smart-contract/types/bn.js.map +1 -1
- package/dist/esm/smart-contract/types/index.js +1 -1
- package/dist/esm/smart-contract/types/index.js.map +1 -1
- package/dist/esm/smart-contract/types/opCode.js +1 -1
- package/dist/esm/smart-contract/types/primitives.js +17 -9
- package/dist/esm/smart-contract/types/primitives.js.map +1 -1
- package/dist/esm/utils/checkIntegrity.js +2 -2
- package/dist/esm/utils/common.js +10 -36
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/esm/utils/constants.js +3 -0
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/index.js +2 -2
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/proof.js +15 -36
- package/dist/esm/utils/proof.js.map +1 -1
- package/dist/types/features/call.d.ts +40 -12
- package/dist/types/features/call.d.ts.map +1 -1
- package/dist/types/features/deploy.d.ts +14 -7
- package/dist/types/features/deploy.d.ts.map +1 -1
- package/dist/types/features/deployGenesis.d.ts +27 -0
- package/dist/types/features/deployGenesis.d.ts.map +1 -0
- package/dist/types/features/index.d.ts +1 -0
- package/dist/types/features/index.d.ts.map +1 -1
- package/dist/types/globalTypes.d.ts +33 -13
- package/dist/types/globalTypes.d.ts.map +1 -1
- package/dist/types/index.d.ts +6 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/networks.d.ts +3 -4
- package/dist/types/networks.d.ts.map +1 -1
- package/dist/types/providers/chainProvider.d.ts +4 -0
- package/dist/types/providers/chainProvider.d.ts.map +1 -1
- package/dist/types/providers/dummyProvider.d.ts.map +1 -1
- package/dist/types/providers/rpcProvider.d.ts +1 -1
- package/dist/types/providers/utxoProvider.d.ts +5 -1
- package/dist/types/providers/utxoProvider.d.ts.map +1 -1
- package/dist/types/psbt/bufferutils.d.ts +7 -2
- package/dist/types/psbt/bufferutils.d.ts.map +1 -1
- package/dist/types/psbt/extPsbt.d.ts +332 -32
- package/dist/types/psbt/extPsbt.d.ts.map +1 -1
- package/dist/types/psbt/psbt.d.ts +4 -5
- package/dist/types/psbt/psbt.d.ts.map +1 -1
- package/dist/types/psbt/psbtutils.d.ts.map +1 -1
- package/dist/types/psbt/signatureutils.d.ts +19 -6
- package/dist/types/psbt/signatureutils.d.ts.map +1 -1
- package/dist/types/psbt/types.d.ts +66 -17
- package/dist/types/psbt/types.d.ts.map +1 -1
- package/dist/types/signers/defaultSigner.d.ts +26 -3
- package/dist/types/signers/defaultSigner.d.ts.map +1 -1
- package/dist/types/signers/unisatSigner.d.ts +27 -1
- package/dist/types/signers/unisatSigner.d.ts.map +1 -1
- package/dist/types/smart-contract/abi.d.ts +68 -13
- package/dist/types/smart-contract/abi.d.ts.map +1 -1
- package/dist/types/smart-contract/abstractContract.d.ts +2 -14
- package/dist/types/smart-contract/abstractContract.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/backtrace.d.ts +13 -0
- package/dist/types/smart-contract/builtin-libs/backtrace.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/contextUtils.d.ts +87 -9
- package/dist/types/smart-contract/builtin-libs/contextUtils.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/p2pk.d.ts +9 -0
- package/dist/types/smart-contract/builtin-libs/p2pk.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/p2pkh.d.ts +10 -0
- package/dist/types/smart-contract/builtin-libs/p2pkh.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/stateLib.d.ts +22 -5
- package/dist/types/smart-contract/builtin-libs/stateLib.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/stateUtils.d.ts +6 -2
- package/dist/types/smart-contract/builtin-libs/stateUtils.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/stdUtils.d.ts +64 -13
- package/dist/types/smart-contract/builtin-libs/stdUtils.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/txHashPreimageUtils.d.ts +27 -0
- package/dist/types/smart-contract/builtin-libs/txHashPreimageUtils.d.ts.map +1 -1
- package/dist/types/smart-contract/builtin-libs/txUtils.d.ts +9 -3
- package/dist/types/smart-contract/builtin-libs/txUtils.d.ts.map +1 -1
- package/dist/types/smart-contract/consts.d.ts +0 -10
- package/dist/types/smart-contract/consts.d.ts.map +1 -1
- package/dist/types/smart-contract/deserializer.d.ts +7 -0
- package/dist/types/smart-contract/deserializer.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/assert.d.ts +1 -1
- package/dist/types/smart-contract/fns/bitwise.d.ts +4 -4
- package/dist/types/smart-contract/fns/byteString.d.ts +8 -5
- package/dist/types/smart-contract/fns/byteString.d.ts.map +1 -1
- package/dist/types/smart-contract/fns/equals.d.ts +1 -1
- package/dist/types/smart-contract/fns/exit.d.ts +9 -0
- package/dist/types/smart-contract/fns/exit.d.ts.map +1 -0
- package/dist/types/smart-contract/fns/fill.d.ts +1 -1
- package/dist/types/smart-contract/fns/index.d.ts +1 -0
- package/dist/types/smart-contract/fns/index.d.ts.map +1 -1
- package/dist/types/smart-contract/fns/math.d.ts +4 -4
- package/dist/types/smart-contract/methods/backtraceToGenensis.d.ts +12 -8
- package/dist/types/smart-contract/methods/backtraceToGenensis.d.ts.map +1 -1
- package/dist/types/smart-contract/methods/checkCtx.d.ts +10 -9
- package/dist/types/smart-contract/methods/checkCtx.d.ts.map +1 -1
- package/dist/types/smart-contract/methods/checkInputState.d.ts +1 -0
- package/dist/types/smart-contract/methods/checkInputState.d.ts.map +1 -1
- package/dist/types/smart-contract/methods/checkInputStateHashes.d.ts +3 -2
- package/dist/types/smart-contract/methods/checkInputStateHashes.d.ts.map +1 -1
- package/dist/types/smart-contract/methods/checkSHPreimage.d.ts +4 -3
- package/dist/types/smart-contract/methods/checkSHPreimage.d.ts.map +1 -1
- package/dist/types/smart-contract/methods/checkSig.d.ts +20 -4
- package/dist/types/smart-contract/methods/checkSig.d.ts.map +1 -1
- package/dist/types/smart-contract/serializer.d.ts +2 -32
- package/dist/types/smart-contract/serializer.d.ts.map +1 -1
- package/dist/types/smart-contract/smartContract.d.ts +61 -27
- package/dist/types/smart-contract/smartContract.d.ts.map +1 -1
- package/dist/types/smart-contract/smartContractLib.d.ts +5 -0
- package/dist/types/smart-contract/smartContractLib.d.ts.map +1 -1
- package/dist/types/smart-contract/stateSerializer.d.ts +17 -0
- package/dist/types/smart-contract/stateSerializer.d.ts.map +1 -1
- package/dist/types/smart-contract/types/abi.d.ts +13 -0
- package/dist/types/smart-contract/types/abi.d.ts.map +1 -1
- package/dist/types/smart-contract/types/artifact.d.ts +19 -6
- package/dist/types/smart-contract/types/artifact.d.ts.map +1 -1
- package/dist/types/smart-contract/types/bn.d.ts +18 -0
- package/dist/types/smart-contract/types/bn.d.ts.map +1 -1
- package/dist/types/smart-contract/types/context.d.ts +6 -8
- package/dist/types/smart-contract/types/context.d.ts.map +1 -1
- package/dist/types/smart-contract/types/index.d.ts +1 -1
- package/dist/types/smart-contract/types/index.d.ts.map +1 -1
- package/dist/types/smart-contract/types/opCode.d.ts +1 -1
- package/dist/types/smart-contract/types/primitives.d.ts +38 -12
- package/dist/types/smart-contract/types/primitives.d.ts.map +1 -1
- package/dist/types/smart-contract/types/structs.d.ts +8 -8
- package/dist/types/utils/checkIntegrity.d.ts +3 -3
- package/dist/types/utils/common.d.ts +7 -17
- package/dist/types/utils/common.d.ts.map +1 -1
- package/dist/types/utils/constants.d.ts +3 -0
- package/dist/types/utils/constants.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/proof.d.ts +13 -13
- package/dist/types/utils/proof.d.ts.map +1 -1
- package/package.json +77 -79
- package/scrypt.index.json +4 -4
- package/src/smart-contract/builtin-libs/backtrace.ts +15 -1
- package/src/smart-contract/builtin-libs/byteStringReader.ts +4 -4
- package/src/smart-contract/builtin-libs/byteStringWriter.ts +2 -2
- package/src/smart-contract/builtin-libs/contextUtils.ts +104 -51
- package/src/smart-contract/builtin-libs/p2pk.ts +9 -0
- package/src/smart-contract/builtin-libs/p2pkh.ts +10 -0
- package/src/smart-contract/builtin-libs/stateLib.ts +28 -12
- package/src/smart-contract/builtin-libs/stateUtils.ts +8 -5
- package/src/smart-contract/builtin-libs/stdUtils.ts +77 -21
- package/src/smart-contract/builtin-libs/txHashPreimageUtils.ts +27 -1
- package/src/smart-contract/builtin-libs/txUtils.ts +19 -12
- package/src/smart-contract/types/structs.ts +8 -8
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
[](https://github.com/OPCAT-Labs/ts-tools/actions/workflows/ci.yml)
|
|
2
|
+
|
|
3
|
+
# scrypt-ts-opcat
|
|
4
|
+
|
|
5
|
+
`scrypt-ts-opcat` is a Typescript framework to write smart contracts on Opcat blockchains.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Use this `npm` to install `scrypt-ts-opcat`:
|
|
10
|
+
|
|
11
|
+
`npm install @opcat-labs/scrypt-ts-opcat`
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Write a Contract
|
|
16
|
+
|
|
17
|
+
A contract can be written as a class that extends the `SmartContract` base, a simple example could be like this:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { SmartContract, method, prop, assert } from "@opcat-labs/scrypt-ts-opcat";
|
|
21
|
+
|
|
22
|
+
class Demo extends SmartContract {
|
|
23
|
+
@prop()
|
|
24
|
+
x: bigint;
|
|
25
|
+
|
|
26
|
+
constructor(x: bigint) {
|
|
27
|
+
super(x);
|
|
28
|
+
this.x = x;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@method()
|
|
32
|
+
public unlock(x: bigint) {
|
|
33
|
+
assert(this.add(this.x, 1n) === x);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@method()
|
|
37
|
+
add(x0: bigint, x1:bigint) : bigint {
|
|
38
|
+
return x0 + x1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Property Decorator: `@prop()`
|
|
44
|
+
|
|
45
|
+
Use this decorator on class properties to mark them as contract properties, which means the values would be stored on chain.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
#### Method Decorator: `@method()`
|
|
49
|
+
|
|
50
|
+
Use this decorator on class methods to mark them as contract methods. The logic implemented in these methods would be stored and be executed on chain.
|
|
51
|
+
|
|
52
|
+
The class methods decorated by `@method()` have some special requirements / restrains that should be followed:
|
|
53
|
+
|
|
54
|
+
* Within these methods, only functions provided as built-ins from `@opcat-labs/scrypt-ts-opcat` or methods also decorated by `@method()` can be called; Similarly, only the properties decorated by `@prop()` can be use.
|
|
55
|
+
|
|
56
|
+
* With `public` modifier, a method is marked as an entry method that could be called outside the contract class. The main purpose of these methods is to validate / verify / check assertions for its input parameters according to its `@prop()` decorated properties. The return value must be `void`.
|
|
57
|
+
|
|
58
|
+
* Without a `public` modifier, a method is kind of an inner function usually be called within the contract class. It can return any valid types.
|
|
59
|
+
|
|
60
|
+
#### Types
|
|
61
|
+
|
|
62
|
+
The types can be used in `@prop()` and `@method()` are restricted to these kinds:
|
|
63
|
+
|
|
64
|
+
* Basic types: `boolean` / `ByteString` / `bigint`;
|
|
65
|
+
|
|
66
|
+
*Note*: the type `number` is not allowed in `@prop()` because it may cause precision issues when representing a floating point number. It can only be used in a few cases like when using `FixedArray` or `Loop`.
|
|
67
|
+
|
|
68
|
+
* User types can be defined using `type` or `interface`, made of basic types. For example,
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
type ST = {
|
|
72
|
+
a: bigint;
|
|
73
|
+
b: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface ST1 {
|
|
77
|
+
x: ST;
|
|
78
|
+
y: ByteString;
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
* Array types **must** be declared using `FixedArray`, whose length must be known at compile time, like:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
let aaa: FixedArray<bigint, 3> = [1n, 3n, 3n];
|
|
86
|
+
|
|
87
|
+
// 2d array
|
|
88
|
+
let abb: FixedArray<FixedArray<bigint, 2>, 3> = [[1n, 3n], [1n, 3n], [1n, 3n]];
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
* Other `SmartContract` subclasses are provided as libraries.
|
|
92
|
+
|
|
93
|
+
#### Statements
|
|
94
|
+
|
|
95
|
+
There are also some other restraints / rules on the statemets that could be used within the `@method`s besides the previously mentioned.
|
|
96
|
+
|
|
97
|
+
##### `for` statement
|
|
98
|
+
|
|
99
|
+
Because of the underlaying limitation of `loop` implemetion on Bitcoin script, one can only use a compile time const number as the loop iterations.
|
|
100
|
+
|
|
101
|
+
So currently if you want to build a loop inside `@method`s, there is only one restricted version of `for` statement that could be used. It's looks like:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
for(let $i = 0; $i < $constNum; $i++) {
|
|
105
|
+
...
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Note that the initial value `0` and the `<` operator and the post unary operator `++` are all unchangeable.
|
|
110
|
+
|
|
111
|
+
* `$i` can be whatever you named the induction variable;
|
|
112
|
+
|
|
113
|
+
* `$constNum` should be an expression of a CTC numeric value of the followings:
|
|
114
|
+
|
|
115
|
+
A number literal like:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
for(let i = 0; i < 5; i++ ) ...
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Or a `const` variable name like:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
const N = 3;
|
|
125
|
+
for(let i = 0; i < N; i++ ) ...
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Or a `readonly` property name like:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
class X {
|
|
132
|
+
static readonly N = 3;
|
|
133
|
+
}
|
|
134
|
+
for(let i = 0; i < X.N; i++ ) ...
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
##### `console.log` statement
|
|
138
|
+
|
|
139
|
+
As described before, all Javascript/Typescript built-in functions/global variables are not allowed in `@method`s, with only a few exceptions.
|
|
140
|
+
|
|
141
|
+
One exceptional statement is `console.log`, which can be used for debugging purpose.
|
|
142
|
+
```ts
|
|
143
|
+
@method
|
|
144
|
+
add(x0: bigint, x1:bigint) : bigint {
|
|
145
|
+
console.log(x0);
|
|
146
|
+
return x0 + x1;
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Compile a Contract
|
|
151
|
+
|
|
152
|
+
Just run `npx opcat-cli@latest compile`, the contract will be compiled if there is no any issue and output the contract json file in the `artifact` folder inside the project.
|
|
153
|
+
|
|
154
|
+
### Test a Contract
|
|
155
|
+
|
|
156
|
+
You could write tests using tools like `mocha`, for example:
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
import { use, expect } from 'chai';
|
|
160
|
+
import chaiAsPromised from 'chai-as-promised';
|
|
161
|
+
import {
|
|
162
|
+
Signer,
|
|
163
|
+
deploy,
|
|
164
|
+
ExtPsbt,
|
|
165
|
+
ChainProvider,
|
|
166
|
+
UtxoProvider,
|
|
167
|
+
call,
|
|
168
|
+
} from '@opcat-labs/scrypt-ts-opcat';
|
|
169
|
+
import { network } from '../utils/privateKey.js';
|
|
170
|
+
import { createLogger, getDefaultProvider, getDefaultSigner } from '../utils/index.js';
|
|
171
|
+
import { Demo } from '../contracts/demo.js';
|
|
172
|
+
|
|
173
|
+
import artifact from '../fixtures/demo.json' with { type: 'json' };
|
|
174
|
+
|
|
175
|
+
use(chaiAsPromised);
|
|
176
|
+
|
|
177
|
+
describe('Test Demo onchain', () => {
|
|
178
|
+
let signer: Signer;
|
|
179
|
+
let provider: ChainProvider & UtxoProvider;
|
|
180
|
+
let pubKey: string;
|
|
181
|
+
let demo: Demo;
|
|
182
|
+
const logger = createLogger('Test Demo onchain');
|
|
183
|
+
|
|
184
|
+
before(async () => {
|
|
185
|
+
Demo.loadArtifact(artifact);
|
|
186
|
+
signer = getDefaultSigner()
|
|
187
|
+
pubKey = await signer.getPublicKey();
|
|
188
|
+
provider = getDefaultProvider(network)
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('should deploy successfully', async () => {
|
|
192
|
+
demo = new Demo(1n, 2n);
|
|
193
|
+
const psbt = await deploy(signer, provider, demo);
|
|
194
|
+
expect(psbt.isFinalized).to.be.true;
|
|
195
|
+
logger.info('deployed successfully, txid: ', psbt.extractTransaction().id);
|
|
196
|
+
psbt.getChangeUTXO() && provider.addNewUTXO(psbt.getChangeUTXO()); // add change utxo
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should unlock successfully', async () => {
|
|
200
|
+
const psbt = await call(signer, provider, demo, (demo: Demo, psbt: ExtPsbt) => {
|
|
201
|
+
demo.add(3n);
|
|
202
|
+
});
|
|
203
|
+
expect(psbt.isFinalized).to.be.true;
|
|
204
|
+
|
|
205
|
+
const txid = await provider.broadcast(psbt.extractTransaction().toHex());
|
|
206
|
+
logger.info('unlocked successfully, txid: ', txid);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Documentation
|
|
213
|
+
|
|
214
|
+
The full version of `Opcat` documentation is available [here](https://docs.opcatlabs.io/overview).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[],[],[],[[8,0,
|
|
1
|
+
[[],[],[],[],[[8,0,14,13]],[[2,0,25,2],[18,0,25,9],[46,0,25,53],[61,0,25,37],[79,0,25,70]],[[4,0,26,4],[12,0,26,11],[16,0,26,15],[30,0,26,30],[40,0,26,11],[43,0,26,42]],[[4,0,27,23],[8,0,27,10],[21,0,27,23],[29,0,27,32],[50,0,27,52],[64,0,27,67],[76,0,27,78]],[[4,0,28,24],[8,0,28,10],[22,0,28,24],[30,0,28,33],[51,0,28,53],[65,0,28,68],[78,0,28,80]],[[4,0,29,4],[11,0,29,11],[19,0,30,6],[33,0,30,21],[42,0,30,6],[44,0,31,6],[52,0,31,15],[65,0,31,27],[77,0,30,6],[79,0,32,6],[93,0,32,21],[104,0,30,6],[106,0,33,6],[114,0,33,15],[127,0,33,27],[140,0,30,6],[142,0,34,6],[156,0,34,21],[168,0,30,6],[170,0,35,6],[184,0,35,21]],[],[[2,0,45,2],[18,0,45,9],[37,0,45,44],[52,0,45,28],[68,0,45,72],[72,0,45,60],[86,0,45,81]],[[4,0,46,4],[11,0,46,17],[25,0,46,32],[36,0,46,43],[47,0,46,43],[49,0,46,56],[55,0,46,76],[66,0,46,76],[68,0,46,89],[71,0,46,75],[73,0,46,95]],[],[[2,0,56,2],[18,0,56,9],[38,0,56,45],[53,0,56,29],[69,0,56,74],[73,0,56,61],[88,0,56,83]],[[4,0,57,4],[11,0,57,17],[25,0,57,32],[37,0,57,44],[49,0,57,44],[51,0,57,58],[57,0,57,79],[69,0,57,79],[71,0,57,93],[74,0,57,78],[76,0,57,99]],[],[]]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[],[],[],[],[],[[7,0,
|
|
1
|
+
[[],[],[],[],[],[],[[7,0,16,36]],[[2,0,17,18],[8,0,17,2]],[[2,0,18,20],[8,0,18,2]],[],[],[[8,0,26,13]],[[2,0,38,2],[18,0,38,9],[42,0,39,20],[57,0,39,4],[73,0,40,16],[79,0,40,4],[91,0,41,18],[95,0,41,4]],[[4,0,43,19],[10,0,43,10],[19,0,43,19],[38,0,43,39],[67,0,43,67]],[[4,0,44,4],[12,0,44,11],[19,0,44,11],[22,0,44,27],[33,0,44,39],[46,0,44,39],[48,0,44,54],[53,0,44,59],[66,0,44,59],[68,0,44,74],[71,0,44,59],[73,0,44,80]],[],[],[[2,0,55,2],[18,0,55,9],[37,0,56,19],[51,0,56,4],[66,0,57,23],[72,0,57,4],[91,0,58,18],[97,0,58,4],[111,0,59,23],[117,0,59,4]],[[4,0,61,16],[26,0,61,10],[32,0,61,16],[41,0,61,26],[57,0,61,41],[72,0,61,56]],[[4,0,62,4],[12,0,63,6],[15,0,63,10],[33,0,63,6],[36,0,63,31],[54,0,63,6],[57,0,63,52],[60,0,63,56],[76,0,63,52],[79,0,63,74]],[],[],[[2,0,77,2],[18,0,77,9],[35,0,78,19],[49,0,78,4],[64,0,79,21],[70,0,79,4],[87,0,80,18],[93,0,80,4],[107,0,81,23],[113,0,81,4]],[[4,0,83,16],[26,0,83,10],[32,0,83,16],[41,0,83,26],[57,0,83,41],[72,0,83,56]],[[4,0,84,4],[12,0,85,6],[15,0,85,10],[31,0,85,6],[34,0,85,28],[50,0,85,6],[53,0,85,47],[56,0,85,51],[72,0,85,47],[75,0,85,69]],[],[],[[2,0,99,2],[18,0,99,9],[33,0,100,19],[47,0,100,4],[62,0,101,23],[68,0,101,4],[89,0,102,5]],[[4,0,104,4],[12,0,106,8],[30,0,107,8],[43,0,107,22],[61,0,107,8],[63,0,107,41],[69,0,108,9],[82,0,108,23],[100,0,108,9],[102,0,108,42],[105,0,108,8],[107,0,108,48],[111,0,105,6],[114,0,110,6],[121,0,110,14],[133,0,110,25],[146,0,110,39]],[[4,0,113,27],[10,0,113,10],[27,0,113,27],[40,0,113,41],[52,0,113,53]],[[4,0,114,4],[12,0,115,6],[27,0,115,6],[30,0,116,8],[49,0,116,28],[78,0,116,56],[91,0,116,70]],[[4,0,120,6],[10,0,119,10],[27,0,121,8],[40,0,121,22],[59,0,121,41],[71,0,122,8],[84,0,122,22],[96,0,122,34],[113,0,122,8],[115,0,122,52],[118,0,122,8],[120,0,122,73],[125,0,123,9],[138,0,123,23],[150,0,123,35],[168,0,123,8],[170,0,123,54],[173,0,123,8],[175,0,123,75],[177,0,123,8],[179,0,123,104]],[[4,0,126,6],[10,0,125,10],[29,0,126,6],[44,0,126,6],[46,0,126,23],[54,0,126,32],[74,0,126,51],[87,0,126,65],[99,0,126,77]],[[4,0,127,4],[11,0,127,11]],[],[]]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[],[],[[8,0,10,13]],[[2,0,13,9],[8,0,13,4]],[[2,0,15,9],[6,0,15,4]],[[2,0,17,4],[14,0,17,21],[20,0,17,16]],[[4,0,19,8],[8,0,19,13],[13,0,19,8],[15,0,19,19]],[[4,0,20,8],[8,0,20,13],[13,0,20,8],[15,0,20,19]],[],[[11,0,28,4],[19,0,28,11]],[[4,0,29,8],[11,0,29,15],[15,0,29,20],[20,0,29,15],[23,0,29,27],[27,0,29,31],[31,0,29,36]],[],[[11,0,37,4],[25,0,37,17]],[[4,0,38,15],[8,0,38,12],[12,0,38,24]],[[4,0,39,
|
|
1
|
+
[[],[],[],[[8,0,10,13]],[[2,0,13,9],[8,0,13,4]],[[2,0,15,9],[6,0,15,4]],[[2,0,17,4],[14,0,17,21],[20,0,17,16]],[[4,0,19,8],[8,0,19,13],[13,0,19,8],[15,0,19,19]],[[4,0,20,8],[8,0,20,13],[13,0,20,8],[15,0,20,19]],[],[[11,0,28,4],[19,0,28,11]],[[4,0,29,8],[11,0,29,15],[15,0,29,20],[20,0,29,15],[23,0,29,27],[27,0,29,31],[31,0,29,36]],[],[[11,0,37,4],[25,0,37,17]],[[4,0,38,15],[8,0,38,12],[12,0,38,24]],[[4,0,39,19],[10,0,39,14],[16,0,39,32],[20,0,39,37]],[[4,0,40,17],[10,0,40,12],[16,0,40,43]],[[4,0,41,22],[8,0,41,14],[17,0,41,31],[24,0,41,53],[28,0,41,58],[33,0,41,63],[37,0,41,68],[44,0,41,73],[48,0,41,78],[53,0,41,73],[55,0,41,84]],[[4,0,42,8],[8,0,42,13],[12,0,42,8]],[[4,0,44,8],[7,0,44,12],[14,0,44,12],[16,0,44,21]],[[8,0,45,12],[10,0,45,12],[12,0,45,16]],[[8,0,46,12],[12,0,46,12],[14,0,46,24],[18,0,46,29],[22,0,46,34],[29,0,46,39],[33,0,46,44],[38,0,46,39],[40,0,46,50]],[[13,0,48,13],[16,0,48,17],[23,0,48,17],[26,0,48,27]],[[8,0,49,12],[10,0,49,12],[12,0,49,16],[20,0,49,25],[36,0,49,46],[40,0,49,51],[44,0,49,56],[51,0,49,61],[55,0,49,66],[60,0,49,61],[62,0,49,72]],[[8,0,50,12],[12,0,50,17],[17,0,50,12],[20,0,50,24]],[[8,0,51,12],[12,0,51,12],[14,0,51,24],[18,0,51,29],[23,0,51,34],[27,0,51,39],[34,0,51,44],[38,0,51,49],[43,0,51,44],[45,0,51,55]],[[13,0,53,13],[16,0,53,17],[23,0,53,17],[26,0,53,27]],[[8,0,54,12],[10,0,54,12],[12,0,54,16],[20,0,54,25],[36,0,54,46],[40,0,54,51],[45,0,54,56],[49,0,54,61],[56,0,54,66],[60,0,54,71],[65,0,54,66],[67,0,54,77]],[[8,0,55,12],[12,0,55,17],[17,0,55,12],[20,0,55,24]],[[8,0,56,12],[12,0,56,12],[14,0,56,24],[18,0,56,29],[23,0,56,34],[27,0,56,39],[34,0,56,44],[38,0,56,49],[43,0,56,44],[45,0,56,55]],[[13,0,58,13],[16,0,58,17],[23,0,58,17],[26,0,58,27]],[[8,0,59,12],[10,0,59,12],[12,0,59,16],[20,0,59,25],[36,0,59,46],[40,0,59,51],[45,0,59,56],[49,0,59,61],[56,0,59,66],[60,0,59,71],[65,0,59,66],[67,0,59,77]],[[8,0,60,12],[12,0,60,17],[17,0,60,12],[20,0,60,24]],[[8,0,61,12],[12,0,61,12],[14,0,61,24],[18,0,61,29],[23,0,61,34],[27,0,61,39],[34,0,61,44],[38,0,61,49],[43,0,61,44],[45,0,61,55]],[],[[8,0,65,12],[16,0,65,19]],[],[[4,0,68,8],[8,0,68,13],[13,0,68,8],[16,0,68,20]],[[4,0,69,8],[11,0,69,15]],[],[[11,0,78,4],[24,0,78,16]],[[4,0,79,19],[10,0,79,14],[16,0,79,38],[20,0,79,43],[25,0,79,48],[29,0,79,53],[36,0,79,58],[40,0,79,63],[45,0,79,58],[47,0,79,69]],[[4,0,80,8],[8,0,80,13],[12,0,80,8]],[[4,0,81,8],[11,0,81,28],[17,0,81,15],[20,0,81,37]],[],[[11,0,89,4],[26,0,89,18]],[[4,0,90,18],[10,0,90,12],[16,0,90,31]],[[4,0,91,23],[10,0,91,14],[19,0,91,29],[23,0,91,34],[28,0,91,39],[32,0,91,44],[39,0,91,49],[43,0,91,54],[48,0,91,49],[50,0,91,60]],[[4,0,92,8],[8,0,92,13],[12,0,92,8]],[[4,0,93,8],[7,0,93,12],[14,0,93,12],[17,0,93,35]],[[8,0,94,12],[12,0,94,12],[14,0,94,24],[18,0,94,29],[23,0,94,34],[27,0,94,39],[34,0,94,44],[38,0,94,49],[43,0,94,44],[45,0,94,55]],[[8,0,95,12],[12,0,95,17],[17,0,95,12],[20,0,95,24]],[[13,0,97,13],[16,0,97,17],[23,0,97,17],[26,0,97,40]],[[8,0,98,12],[12,0,98,12],[14,0,98,24],[18,0,98,29],[23,0,98,34],[27,0,98,39],[34,0,98,44],[38,0,98,49],[43,0,98,44],[45,0,98,55]],[[8,0,99,12],[12,0,99,17],[17,0,99,12],[20,0,99,24]],[[13,0,101,13],[16,0,101,17],[23,0,101,17],[26,0,101,40]],[[8,0,102,12],[12,0,102,12],[14,0,102,24],[18,0,102,29],[23,0,102,34],[27,0,102,39],[34,0,102,44],[38,0,102,49],[43,0,102,44],[45,0,102,55]],[[8,0,103,12],[12,0,103,17],[17,0,103,12],[20,0,103,24]],[],[[8,0,106,12],[12,0,106,12],[14,0,106,18]],[],[[4,0,108,8],[11,0,108,15],[19,0,108,24],[35,0,108,39]],[],[]]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[],[],[[8,0,10,13]],[[2,0,12,9],[8,0,12,4]],[[2,0,14,4]],[[4,0,16,8],[8,0,16,13],[13,0,16,8],[15,0,16,32]],[],[[11,0,24,4],[22,0,24,20],[28,0,24,15]],[[4,0,25,
|
|
1
|
+
[[],[],[],[[8,0,10,13]],[[2,0,12,9],[8,0,12,4]],[[2,0,14,4]],[[4,0,16,8],[8,0,16,13],[13,0,16,8],[15,0,16,32]],[],[[11,0,24,4],[22,0,24,20],[28,0,24,15]],[[4,0,25,18],[8,0,25,14],[12,0,25,18],[16,0,25,22]],[[4,0,27,20],[10,0,27,12],[19,0,27,46]],[[4,0,29,8],[7,0,29,12],[9,0,29,12],[11,0,29,16]],[[8,0,30,12],[15,0,30,12],[17,0,30,21],[25,0,30,30],[39,0,30,43],[42,0,30,46]],[[13,0,32,13],[16,0,32,17],[18,0,32,17],[20,0,32,21]],[[8,0,33,12],[15,0,33,12],[17,0,33,34],[23,0,33,21],[25,0,33,42],[33,0,33,51],[47,0,33,64],[50,0,33,67]],[[13,0,35,13],[16,0,35,17],[18,0,35,17],[20,0,35,21]],[[8,0,36,12],[15,0,36,12],[17,0,36,34],[23,0,36,21],[25,0,36,42],[33,0,36,51],[47,0,36,64],[50,0,36,67]],[[13,0,38,13],[16,0,38,17],[18,0,38,17],[20,0,38,21]],[[8,0,39,12],[15,0,39,12],[17,0,39,34],[23,0,39,21],[25,0,39,42],[33,0,39,51],[47,0,39,64],[50,0,39,67]],[],[[8,0,43,12],[16,0,43,19]],[],[[4,0,46,8],[8,0,46,13],[13,0,46,8],[16,0,46,20],[23,0,46,20],[25,0,46,29]],[],[],[[11,0,55,4],[21,0,55,17],[26,0,55,14]],[[4,0,56,8],[8,0,56,13],[13,0,56,8],[16,0,56,20],[20,0,56,37],[28,0,56,58]],[],[],[[11,0,65,4],[23,0,65,19],[27,0,65,16]],[[4,0,66,8],[12,0,66,15],[14,0,66,15],[17,0,66,20]],[[4,0,67,19],[8,0,67,12],[15,0,67,19]],[[4,0,68,8],[7,0,68,12],[9,0,68,12],[11,0,68,16]],[[8,0,69,12],[13,0,69,12],[15,0,69,19]],[[13,0,71,13],[16,0,71,17],[18,0,71,17],[20,0,71,21]],[[8,0,72,12],[12,0,72,17],[17,0,72,12],[20,0,72,37]],[[8,0,73,12],[13,0,73,12],[15,0,73,19]],[[13,0,75,13],[16,0,75,17],[18,0,75,17],[20,0,75,21]],[[8,0,76,12],[13,0,76,12],[15,0,76,19]],[[8,0,77,12],[12,0,77,17],[17,0,77,12],[20,0,77,37]],[],[[8,0,80,12],[13,0,80,12],[15,0,80,19]],[[8,0,81,12],[12,0,81,17],[17,0,81,12],[20,0,81,37]],[],[[4,0,83,8],[8,0,83,13],[13,0,83,8],[16,0,83,20],[24,0,83,29],[38,0,83,42],[41,0,83,45]],[],[],[]]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[],[],[],[],[[8,0,
|
|
1
|
+
[[],[],[],[],[],[[8,0,24,13]],[[2,0,29,2],[9,0,29,9],[15,0,29,27],[23,0,29,18],[33,0,29,37],[41,0,29,45]],[[2,0,31,2],[9,0,31,9],[15,0,31,26],[22,0,31,18],[31,0,31,35],[38,0,31,55]],[[2,0,34,2],[9,0,34,9],[15,0,34,24],[19,0,34,18],[26,0,34,33]],[[2,0,37,2],[9,0,37,9],[15,0,37,21],[19,0,37,18],[23,0,37,30]],[[2,0,40,2],[9,0,40,9],[15,0,40,30],[21,0,40,18],[34,0,40,56]],[[2,0,50,2],[18,0,50,9],[28,0,50,22],[32,0,50,19],[35,0,50,39],[39,0,50,30],[50,0,50,48]],[[4,0,51,15],[8,0,51,10],[14,0,51,24],[16,0,51,24],[18,0,51,28]],[[4,0,53,4],[12,0,53,12],[16,0,53,12],[18,0,53,18],[23,0,53,23],[27,0,53,23],[29,0,53,29],[39,0,53,39]],[],[[2,0,72,2],[18,0,72,9],[23,0,72,17],[27,0,72,14],[30,0,72,34],[38,0,72,25],[47,0,72,53],[51,0,72,43],[61,0,72,64],[65,0,72,61],[68,0,72,84],[74,0,72,72],[86,0,72,109],[92,0,72,96],[107,0,72,122]],[[4,0,74,11],[8,0,74,8],[12,0,74,20],[21,0,74,20],[24,0,74,32],[26,0,74,32],[28,0,74,36],[30,0,74,36],[32,0,74,40]],[],[[4,0,76,4],[6,0,76,4],[8,0,76,8],[20,0,76,21],[31,0,76,31],[34,0,75,22]],[[4,0,78,4],[7,0,78,8],[9,0,78,8],[11,0,75,22],[90,0,78,12],[92,0,78,16]],[[8,0,79,6],[10,0,79,6],[12,0,75,22],[91,0,79,10],[93,0,79,14]],[],[[4,0,86,16],[8,0,86,10],[15,0,86,25],[16,0,86,32],[20,0,86,36]],[[4,0,87,17],[8,0,87,10],[15,0,87,17],[19,0,87,21],[24,0,87,37]],[[4,0,90,22],[10,0,90,10],[23,0,90,41],[36,0,90,59],[44,0,90,75],[47,0,90,78],[52,0,90,84],[53,0,90,91],[58,0,90,97],[61,0,90,97],[63,0,90,103],[74,0,90,41],[87,0,90,59],[95,0,90,75],[98,0,90,78],[103,0,90,84],[104,0,90,91]],[[4,0,92,13],[8,0,92,10],[12,0,92,22],[14,0,92,22],[16,0,92,27],[21,0,92,22],[23,0,92,34],[24,0,92,41]],[[4,0,94,14],[10,0,94,10],[15,0,94,40],[21,0,94,27],[23,0,95,6],[28,0,95,22],[31,0,94,27],[33,0,96,19],[39,0,94,27],[41,0,97,6],[46,0,97,22],[52,0,94,27],[54,0,98,6],[65,0,94,27],[67,0,99,19],[73,0,94,27],[75,0,100,6],[80,0,100,22],[86,0,94,27],[88,0,101,6],[99,0,94,27],[101,0,102,19]],[[4,0,103,4],[11,0,103,11],[15,0,103,15]],[],[[2,0,112,2],[18,0,112,9],[33,0,112,27],[39,0,112,24],[44,0,112,40]],[[4,0,115,4],[11,0,115,11],[18,0,115,27],[31,0,115,45],[34,0,115,48],[38,0,115,27],[40,0,115,68]],[],[[2,0,127,2],[18,0,127,9],[34,0,127,37],[45,0,127,25],[57,0,127,62],[63,0,127,49],[78,0,127,75]],[[4,0,129,21],[20,0,129,10],[31,0,129,21],[43,0,129,34],[64,0,129,54]],[[4,0,131,13],[10,0,131,10],[14,0,131,26],[22,0,131,34]],[[4,0,132,15],[8,0,132,10],[14,0,132,21],[26,0,132,34],[32,0,133,6],[44,0,133,19],[60,0,133,34],[64,0,134,6],[76,0,134,19],[86,0,34,33],[165,0,37,30],[243,0,137,7],[255,0,137,20],[268,0,138,8]],[[4,0,139,4],[11,0,139,11]],[],[[2,0,150,2],[18,0,150,9],[38,0,150,41],[49,0,150,29],[63,0,150,54]],[[4,0,151,4],[12,0,151,11],[16,0,151,15],[26,0,151,26],[37,0,151,11],[40,0,151,39]],[[4,0,152,4],[12,0,152,11],[16,0,152,15],[26,0,152,26],[41,0,152,11],[44,0,152,43]],[[4,0,153,4],[12,0,153,11],[16,0,153,15],[26,0,153,26],[44,0,153,11],[47,0,153,46]],[[4,0,154,4],[12,0,154,11],[16,0,154,15],[26,0,154,26],[42,0,154,11],[45,0,154,44]],[[4,0,155,4],[12,0,155,11],[22,0,155,22],[29,0,155,11],[32,0,155,31]],[[4,0,156,4],[12,0,156,11],[16,0,156,15],[26,0,156,26],[38,0,156,11],[41,0,156,40]],[[4,0,157,4],[12,0,157,11],[16,0,157,15],[26,0,157,26],[45,0,157,11],[48,0,157,47]],[[4,0,158,4],[12,0,158,11],[16,0,158,15],[26,0,158,26],[50,0,158,11],[53,0,158,52]],[[4,0,159,4],[12,0,159,11],[16,0,159,15],[26,0,159,26],[48,0,159,11],[51,0,159,50]],[[4,0,160,4],[12,0,160,11],[16,0,160,15],[26,0,160,26],[42,0,160,11],[45,0,160,44]],[[4,0,161,4],[12,0,161,11],[16,0,161,15],[26,0,161,26],[40,0,161,11],[43,0,161,42]],[[4,0,162,4],[12,0,162,11],[22,0,162,22],[34,0,162,11],[37,0,162,36]],[[4,0,163,4],[12,0,163,11],[22,0,163,22],[33,0,163,11],[36,0,163,35]],[[4,0,164,4],[12,0,164,11],[22,0,164,22],[35,0,164,11],[38,0,164,37],[40,0,164,11],[43,0,165,9],[53,0,165,20],[66,0,165,9],[69,0,165,35],[71,0,164,11],[74,0,166,9],[84,0,166,20],[97,0,166,9],[100,0,166,35],[102,0,164,11],[105,0,167,9],[115,0,167,20],[128,0,167,9],[131,0,167,35],[136,0,164,11],[139,0,168,9],[149,0,168,20],[162,0,168,9],[165,0,168,35],[170,0,164,11],[173,0,169,9],[183,0,169,20],[196,0,169,9],[199,0,169,35]],[[4,0,172,21],[10,0,172,10],[21,0,172,21],[31,0,172,32],[41,0,172,21],[43,0,173,8],[53,0,173,19],[67,0,172,21],[69,0,174,8],[79,0,174,19],[96,0,172,21],[98,0,175,8],[108,0,175,19],[123,0,172,21],[125,0,176,8],[132,0,176,16],[154,0,176,37],[164,0,176,48],[172,0,172,21],[174,0,177,8],[184,0,177,19],[195,0,172,21],[197,0,178,8],[207,0,178,19],[225,0,172,21],[227,0,179,8],[237,0,179,19],[260,0,172,21],[262,0,180,8],[272,0,180,19],[293,0,172,21],[295,0,181,8],[305,0,181,19],[320,0,172,21],[322,0,182,8],[332,0,182,19],[345,0,172,21],[347,0,183,8],[355,0,183,17],[369,0,183,30],[379,0,183,41],[392,0,183,53],[395,0,172,21],[397,0,184,8],[405,0,184,17],[419,0,184,30],[429,0,184,41],[441,0,184,52],[444,0,172,21],[446,0,185,8],[454,0,185,24],[464,0,185,35],[478,0,185,48]],[[4,0,186,4],[11,0,186,11],[27,0,186,27]],[],[[2,0,198,2],[18,0,198,9],[32,0,199,14],[38,0,199,4],[48,0,200,20],[54,0,200,4],[70,0,201,18],[74,0,201,4],[88,0,202,18],[92,0,202,4],[108,0,203,5]],[[4,0,205,4],[12,0,205,11],[20,0,205,19],[30,0,205,11],[33,0,205,32]],[[4,0,206,4],[12,0,206,11],[25,0,206,11],[27,0,206,26]],[[4,0,207,4],[12,0,207,11],[25,0,207,11],[28,0,207,27],[36,0,207,36],[57,0,207,56],[67,0,207,66]],[[4,0,209,14],[10,0,209,10],[14,0,209,20],[23,0,209,30],[36,0,209,30],[38,0,209,45],[44,0,209,51],[57,0,209,51],[59,0,209,66],[62,0,209,50],[64,0,209,72]],[[4,0,210,4],[11,0,210,11],[12,0,211,20],[14,0,211,23],[18,0,211,27],[23,0,212,19],[31,0,212,28],[51,0,212,53],[53,0,212,56],[58,0,212,61]],[],[[2,0,223,2],[18,0,223,9],[36,0,224,23],[42,0,224,4],[61,0,225,24],[67,0,225,4],[87,0,226,18],[91,0,226,4]],[[4,0,228,4],[12,0,228,11],[20,0,228,19],[39,0,228,11],[42,0,228,41]],[[4,0,229,4],[12,0,229,11],[25,0,229,11],[28,0,229,27],[36,0,229,36],[57,0,229,56],[76,0,229,75]],[],[],[[2,0,239,2],[18,0,239,9],[36,0,240,18],[42,0,240,4],[56,0,241,22],[62,0,241,4],[82,0,242,5]],[[4,0,243,4],[12,0,243,11],[20,0,243,19],[34,0,243,11],[37,0,243,36]],[[4,0,244,4],[11,0,244,11],[19,0,244,20],[40,0,244,40],[54,0,244,54]],[],[[2,0,256,2],[18,0,256,9],[39,0,257,21],[45,0,257,4],[62,0,258,25],[68,0,258,4],[89,0,259,16],[93,0,259,4]],[[4,0,261,4],[12,0,261,11],[20,0,261,19],[37,0,261,11],[40,0,261,39]],[[4,0,262,4],[12,0,262,11],[23,0,262,11],[26,0,262,25],[34,0,262,34],[55,0,262,54],[72,0,262,71]],[],[],[[2,0,273,2],[18,0,273,9],[37,0,274,23],[43,0,274,4],[62,0,275,16],[66,0,275,4],[80,0,276,5]],[[4,0,277,4],[11,0,277,17],[29,0,277,36],[40,0,277,36],[42,0,277,49],[48,0,277,55],[59,0,277,55],[61,0,277,68],[64,0,277,54],[66,0,277,74]],[],[[2,0,287,2],[18,0,287,9],[33,0,288,18],[39,0,288,4],[53,0,289,16],[57,0,289,4],[71,0,290,5]],[[4,0,291,4],[11,0,291,11],[19,0,291,20],[35,0,291,41],[48,0,291,55],[59,0,291,55],[61,0,291,68],[66,0,291,73],[77,0,291,73],[79,0,291,86],[82,0,291,72],[84,0,291,92]],[],[[2,0,301,2],[18,0,301,9],[35,0,302,21],[41,0,302,4],[58,0,303,16],[62,0,303,4],[76,0,304,5]],[[4,0,305,4],[11,0,305,17],[27,0,305,34],[38,0,305,34],[40,0,305,47],[46,0,305,53],[57,0,305,53],[59,0,305,66],[62,0,305,52],[64,0,305,72]],[],[[2,0,315,2],[18,0,315,9],[33,0,316,16],[44,0,316,4],[56,0,317,15],[60,0,317,4],[73,0,318,6]],[[4,0,319,22],[8,0,319,10],[20,0,319,22],[28,0,319,31],[44,0,319,46],[54,0,319,57]],[[4,0,320,4],[12,0,320,12],[22,0,320,12],[24,0,320,24],[35,0,320,12],[39,0,320,40],[49,0,320,40],[51,0,320,52],[63,0,320,65],[73,0,320,76],[84,0,320,65],[86,0,320,88],[98,0,320,101],[104,0,320,12],[107,0,320,110],[117,0,320,121],[128,0,320,110],[131,0,320,134]],[],[]]
|
|
@@ -14,7 +14,7 @@ library ContextUtils {
|
|
|
14
14
|
return (res < 0) ? res + modulus : res;
|
|
15
15
|
}
|
|
16
16
|
static function sign(int h, PrivKey privKey, int inverseK, int r, bytes rBigEndian, bytes sigHashType) : Sig {
|
|
17
|
-
int s = inverseK * (h + r *
|
|
17
|
+
int s = inverseK * (h + r * privKey);
|
|
18
18
|
|
|
19
19
|
s = ContextUtils.normalize(s, 115792089237316195423570985008687907852837564279074904382605163141518161494337);
|
|
20
20
|
if(s > 115792089237316195423570985008687907852837564279074904382605163141518161494337 / 2) {
|
|
@@ -31,21 +31,7 @@ library ContextUtils {
|
|
|
31
31
|
return unpack(reverseBytes(b, 32) + b'00');
|
|
32
32
|
}
|
|
33
33
|
static function checkSHPreimage(SHPreimage shPreimage, bytes sigHashType) : Sig {
|
|
34
|
-
|
|
35
|
-
require(len(shPreimage.hashPrevouts) == 32);
|
|
36
|
-
require(len(shPreimage.spentScriptHash) == 32);
|
|
37
|
-
require(len(shPreimage.spentDataHash) == 32);
|
|
38
|
-
require(shPreimage.value >= 0);
|
|
39
|
-
require(len(shPreimage.nSequence) == 4);
|
|
40
|
-
require(len(shPreimage.hashSpentAmounts) == 32);
|
|
41
|
-
require(len(shPreimage.hashSpentScriptHashes) == 32);
|
|
42
|
-
require(len(shPreimage.hashSpentDataHashes) == 32);
|
|
43
|
-
require(len(shPreimage.hashSequences) == 32);
|
|
44
|
-
require(len(shPreimage.hashOutputs) == 32);
|
|
45
|
-
require(shPreimage.inputIndex >= 0);
|
|
46
|
-
require(shPreimage.nLockTime >= 0);
|
|
47
|
-
require(shPreimage.sigHashType == 1 || shPreimage.sigHashType == 2 || shPreimage.sigHashType == 3 || shPreimage.sigHashType == 0x81 || shPreimage.sigHashType == 0x82 || shPreimage.sigHashType == 0x83);
|
|
48
|
-
bytes preimage = shPreimage.nVersion + shPreimage.hashPrevouts + shPreimage.spentScriptHash + shPreimage.spentDataHash + TxUtils.satoshisToByteString(shPreimage.value) + shPreimage.nSequence + shPreimage.hashSpentAmounts + shPreimage.hashSpentScriptHashes + shPreimage.hashSpentDataHashes + shPreimage.hashSequences + shPreimage.hashOutputs + StdUtils.toLEUnsigned(shPreimage.inputIndex, 4) + StdUtils.toLEUnsigned(shPreimage.nLockTime, 4) + num2bin(shPreimage.sigHashType, 4);
|
|
34
|
+
SigHashPreimage preimage = ContextUtils.serializeSHPreimage(shPreimage);
|
|
49
35
|
bytes h = hash256(preimage);
|
|
50
36
|
Sig sig = ContextUtils.sign(ContextUtils.fromBEUnsigned(h), ContextUtils.privKey, 90914631784428570546048907090666684794265392153046400654824470772421497439242, 7252565254521500021189571868467740368187828957595681190666767817830690399852, ContextUtils.rBigEndian, sigHashType);
|
|
51
37
|
return sig;
|
|
@@ -80,13 +66,13 @@ library ContextUtils {
|
|
|
80
66
|
require(t_inputCount == StdUtils.checkLenDivisibleBy(spentScriptHashes, 32));
|
|
81
67
|
return true;
|
|
82
68
|
}
|
|
83
|
-
static function checkSpentAmounts(bytes spentAmounts, bytes
|
|
84
|
-
require(hash256(spentAmounts) ==
|
|
69
|
+
static function checkSpentAmounts(bytes spentAmounts, bytes hashSpentAmounts) : int {
|
|
70
|
+
require(hash256(spentAmounts) == hashSpentAmounts);
|
|
85
71
|
return StdUtils.checkLenDivisibleBy(spentAmounts, 8);
|
|
86
72
|
}
|
|
87
|
-
static function checkSpentDataHashes(bytes spentDataHashes, bytes
|
|
88
|
-
require(hash256(spentDataHashes) ==
|
|
89
|
-
require(
|
|
73
|
+
static function checkSpentDataHashes(bytes spentDataHashes, bytes hashSpentDataHashes, int inputCount) : bool {
|
|
74
|
+
require(hash256(spentDataHashes) == hashSpentDataHashes);
|
|
75
|
+
require(inputCount == StdUtils.checkLenDivisibleBy(spentDataHashes, 32));
|
|
90
76
|
return true;
|
|
91
77
|
}
|
|
92
78
|
static function getSpentScriptHash(bytes spentScriptHashes, int inputIndex) : bytes {
|
|
@@ -98,4 +84,8 @@ library ContextUtils {
|
|
|
98
84
|
static function getSpentDataHash(bytes spentDataHashes, int inputIndex) : bytes {
|
|
99
85
|
return spentDataHashes[inputIndex * 32 : (inputIndex + 1) * 32];
|
|
100
86
|
}
|
|
87
|
+
static function checknLockTime(SHPreimage shPreimage, int nlockTime) : bool {
|
|
88
|
+
int nSequence = StdUtils.fromLEUnsigned(shPreimage.nSequence);
|
|
89
|
+
return (nSequence < 4294967295 && (nlockTime < 500000000 ? shPreimage.nLockTime < 500000000 : true) && shPreimage.nLockTime >= nlockTime);
|
|
90
|
+
}
|
|
101
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[[9,0,
|
|
1
|
+
[[],[[9,0,14,13]],[[2,0,16,4],[8,0,16,21],[15,0,16,13]],[[2,0,24,4],[18,0,24,11],[25,0,24,23],[29,0,24,18]],[[4,0,25,8],[12,0,25,20],[20,0,25,15],[21,0,25,29],[26,0,25,34],[30,0,25,39],[37,0,25,15]],[],[]]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[[9,0,
|
|
1
|
+
[[],[[9,0,16,13]],[[2,0,18,4],[8,0,18,19],[18,0,18,13]],[[2,0,26,4],[18,0,26,11],[25,0,26,23],[29,0,26,18],[34,0,26,36],[41,0,26,28]],[[4,0,27,8],[12,0,28,12],[20,0,28,24],[28,0,28,12],[31,0,28,35],[35,0,28,40]],[[4,0,31,8],[12,0,31,20],[20,0,31,15],[21,0,31,29],[26,0,31,34],[32,0,31,15]],[],[]]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[[8,0,
|
|
1
|
+
[[],[[8,0,13,13]],[]]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[[8,0,
|
|
1
|
+
[[],[[8,0,17,13]],[[2,0,25,2],[18,0,25,9],[34,0,26,18],[38,0,26,4],[52,0,27,15],[58,0,27,4],[69,0,28,23],[75,0,28,4]],[[4,0,30,4],[12,0,32,8],[30,0,33,8],[43,0,33,8],[45,0,33,23],[51,0,34,9],[64,0,34,9],[66,0,34,24],[69,0,34,8],[71,0,34,30],[75,0,31,6],[78,0,35,11]],[],[],[]]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
library StateUtils {
|
|
3
|
-
static function checkInputState(int t_inputIndex, bytes
|
|
4
|
-
require(t_spentDataHashes[t_inputIndex * 32 : (t_inputIndex + 1) * 32] ==
|
|
3
|
+
static function checkInputState(int t_inputIndex, bytes stateHash, bytes t_spentDataHashes) : bool {
|
|
4
|
+
require(t_spentDataHashes[t_inputIndex * 32 : (t_inputIndex + 1) * 32] == stateHash);
|
|
5
5
|
return true;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[[7,0,12,24]],[[2,0,13,8],[8,0,13,2]],[[2,0,14,11],[6,0,14,2]],[],[],[[8,0,
|
|
1
|
+
[[],[[7,0,12,24]],[[2,0,13,8],[8,0,13,2]],[[2,0,14,11],[6,0,14,2]],[],[],[[8,0,27,13]],[[2,0,36,2],[18,0,36,9],[38,0,36,32],[44,0,36,29],[47,0,36,47],[51,0,36,44],[56,0,36,56]],[[4,0,37,14],[8,0,37,10],[12,0,37,14],[16,0,37,18]],[[4,0,38,4],[12,0,38,11],[14,0,38,11],[16,0,38,15],[18,0,38,11],[21,0,38,20]],[[4,0,39,4],[11,0,39,11],[13,0,39,11],[15,0,39,15]],[],[[2,0,50,2],[18,0,50,9],[37,0,50,31],[41,0,50,28],[46,0,50,40]],[[4,0,51,4],[12,0,51,11],[14,0,51,11],[17,0,8,26],[19,0,51,11],[22,0,51,30],[24,0,51,30],[27,0,7,26]],[[4,0,52,4],[11,0,52,11],[19,0,52,20],[33,0,52,33],[36,0,52,36]],[],[[2,0,62,2],[18,0,62,9],[37,0,62,31],[41,0,62,28],[46,0,62,40]],[[4,0,63,4],[12,0,63,11],[14,0,63,11],[17,0,10,26],[19,0,63,11],[22,0,63,30],[24,0,63,30],[27,0,9,26]],[[4,0,64,4],[11,0,64,11],[19,0,64,20],[33,0,64,33],[36,0,64,36]],[],[[2,0,74,2],[18,0,74,9],[37,0,74,31],[43,0,74,28],[48,0,74,44]],[[4,0,75,4],[12,0,75,11],[16,0,75,15],[19,0,75,11],[22,0,75,21]],[[4,0,76,4],[11,0,76,11],[19,0,76,20],[35,0,76,35]],[],[[2,0,86,2],[18,0,86,9],[31,0,86,25],[35,0,86,22],[38,0,86,36],[42,0,86,33],[47,0,86,45]],[[4,0,87,14],[10,0,87,10],[14,0,87,14],[22,0,87,30],[25,0,87,33],[27,0,87,33],[29,0,87,37]],[[4,0,89,4],[11,0,89,17],[13,0,89,20],[17,0,89,24]],[],[[2,0,98,2],[18,0,98,9],[33,0,98,27],[39,0,98,24],[44,0,98,40]],[[4,0,99,4],[11,0,99,11],[18,0,99,27],[20,0,99,27],[22,0,99,44]],[],[[2,0,113,2],[18,0,113,9],[30,0,113,24],[34,0,113,21],[39,0,113,33]],[[4,0,114,11],[10,0,114,8],[14,0,114,37]],[[4,0,115,15],[8,0,115,8],[15,0,115,15]],[[4,0,116,4],[7,0,116,8],[9,0,116,8],[11,0,116,12]],[[8,0,117,6],[13,0,117,6],[15,0,117,13]],[[13,0,119,9],[16,0,119,13],[18,0,119,13],[20,0,119,17]],[[8,0,120,6],[10,0,120,6],[12,0,120,23]],[[8,0,121,6],[13,0,121,6],[15,0,121,13]],[[13,0,123,9],[16,0,123,13],[18,0,123,13],[20,0,123,17]],[[8,0,124,6],[10,0,124,6],[12,0,124,23]],[[8,0,125,6],[13,0,125,6],[15,0,125,13]],[],[[8,0,128,6],[10,0,128,6],[12,0,128,23]],[[8,0,129,6],[13,0,129,6],[15,0,129,13]],[],[[4,0,131,4],[11,0,131,11],[13,0,131,11],[15,0,131,15],[23,0,131,24],[37,0,131,37],[40,0,131,40]],[],[[2,0,148,2],[18,0,148,9],[27,0,148,23],[33,0,148,18],[40,0,148,36]],[[4,0,149,14],[8,0,149,10],[12,0,149,14],[16,0,149,18]],[[4,0,150,15],[8,0,150,8],[15,0,150,15]],[[4,0,151,16],[10,0,151,8],[19,0,151,42]],[[4,0,153,4],[7,0,153,8],[9,0,153,8],[11,0,153,12]],[[8,0,154,6],[13,0,154,6],[15,0,154,13]],[[8,0,155,6],[15,0,155,6],[17,0,155,28]],[[13,0,157,9],[16,0,157,13],[18,0,157,13],[20,0,157,17]],[[8,0,158,6],[13,0,158,6],[15,0,158,13]],[[8,0,159,6],[15,0,159,6],[17,0,159,28]],[[13,0,161,9],[16,0,161,13],[18,0,161,13],[20,0,161,17]],[[8,0,162,6],[13,0,162,6],[15,0,162,13]],[[8,0,163,6],[15,0,163,6],[17,0,163,28]],[[13,0,165,9],[16,0,165,13],[18,0,165,13],[20,0,165,17]],[[8,0,166,6],[13,0,166,6],[15,0,166,13]],[[8,0,167,6],[15,0,167,6],[17,0,167,28]],[],[[8,0,171,6],[16,0,171,13]],[],[[4,0,174,4],[11,0,174,11],[18,0,174,11],[20,0,174,20],[28,0,174,29],[42,0,174,42],[45,0,174,45]],[],[[2,0,183,2],[18,0,183,9],[29,0,183,25],[35,0,183,20],[40,0,183,42],[44,0,183,37],[51,0,183,51]],[[4,0,184,11],[8,0,184,8],[12,0,184,20]],[[4,0,185,13],[10,0,185,8],[16,0,185,39]],[[4,0,186,17],[8,0,186,8],[18,0,186,26]],[[4,0,187,18],[10,0,187,10],[19,0,187,37],[23,0,187,42],[29,0,187,47],[33,0,187,47],[35,0,187,53]],[[4,0,189,4],[7,0,189,8],[14,0,189,8],[17,0,189,31]],[[8,0,190,6],[10,0,190,6],[12,0,190,10],[20,0,190,19],[36,0,190,40],[40,0,190,45],[44,0,190,45],[46,0,190,51],[50,0,190,55],[54,0,190,55],[56,0,190,61]],[[8,0,191,6],[12,0,191,6],[14,0,191,18],[18,0,191,23],[22,0,191,27],[24,0,191,27],[26,0,191,32]],[[8,0,192,6],[16,0,192,6],[18,0,192,16],[22,0,192,16],[24,0,192,22],[26,0,192,16],[28,0,192,27]],[[13,0,194,9],[16,0,194,13],[23,0,194,13],[26,0,194,36]],[[8,0,195,6],[10,0,195,6],[12,0,195,10],[20,0,195,19],[36,0,195,40],[40,0,195,45],[44,0,195,45],[46,0,195,51],[50,0,195,55],[54,0,195,55],[56,0,195,61]],[[8,0,196,6],[12,0,196,6],[14,0,196,18],[18,0,196,23],[22,0,196,23],[24,0,196,29],[28,0,196,33],[32,0,196,33],[34,0,196,39],[36,0,196,33],[38,0,196,44]],[[8,0,197,6],[16,0,197,6],[18,0,197,16],[22,0,197,16],[24,0,197,22],[26,0,197,16],[28,0,197,27]],[[13,0,199,9],[16,0,199,13],[23,0,199,13],[26,0,199,36]],[[8,0,200,6],[10,0,200,6],[12,0,200,10],[20,0,200,19],[36,0,200,40],[40,0,200,45],[44,0,200,45],[46,0,200,51],[50,0,200,55],[54,0,200,55],[56,0,200,61]],[[8,0,201,6],[12,0,201,6],[14,0,201,18],[18,0,201,23],[22,0,201,23],[24,0,201,29],[28,0,201,33],[32,0,201,33],[34,0,201,39],[36,0,201,33],[38,0,201,44]],[[8,0,202,6],[16,0,202,6],[18,0,202,16],[22,0,202,16],[24,0,202,22],[26,0,202,16],[28,0,202,27]],[],[[8,0,204,6],[10,0,204,6],[12,0,204,10],[20,0,204,19],[36,0,204,40],[40,0,204,45],[46,0,204,50],[50,0,204,50],[52,0,204,56]],[[8,0,205,6],[12,0,205,6],[14,0,205,18],[18,0,205,23],[22,0,205,23],[24,0,205,29],[28,0,205,33],[32,0,205,33],[34,0,205,39],[36,0,205,33],[38,0,205,44]],[[8,0,206,6],[16,0,206,6],[18,0,206,16],[22,0,206,16],[24,0,206,22],[26,0,206,16],[28,0,206,27]],[],[[4,0,209,4],[11,0,209,11],[12,0,209,19],[17,0,209,33]],[],[]]
|
|
@@ -48,19 +48,24 @@ library StdUtils {
|
|
|
48
48
|
}
|
|
49
49
|
static function pushData(bytes buf) : bytes {
|
|
50
50
|
int n = len(buf);
|
|
51
|
+
int size = 0;
|
|
51
52
|
bytes header = b'';
|
|
52
53
|
if(n < 0x4c) {
|
|
53
|
-
|
|
54
|
+
size = 1;
|
|
55
|
+
header = b'';
|
|
54
56
|
} else if(n < 0x100) {
|
|
55
|
-
|
|
57
|
+
size = 1;
|
|
58
|
+
header = b'4c';
|
|
56
59
|
} else if(n < 0x10000) {
|
|
57
|
-
|
|
60
|
+
size = 2;
|
|
61
|
+
header = b'4d';
|
|
58
62
|
} else if(n < 0x100000000) {
|
|
59
|
-
|
|
63
|
+
size = 4;
|
|
64
|
+
header = b'4e';
|
|
60
65
|
} else {
|
|
61
66
|
require(false);
|
|
62
67
|
}
|
|
63
|
-
return header +
|
|
68
|
+
return header + StdUtils.toLEUnsigned(n, size);
|
|
64
69
|
}
|
|
65
70
|
static function readVarint(bytes buf, int pos) : ReadVarintResult {
|
|
66
71
|
int l = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[[],[],[],[],[[8,0,
|
|
1
|
+
[[],[],[],[],[[8,0,25,13]],[[2,0,28,2],[9,0,28,9],[15,0,28,29],[19,0,28,18],[31,0,28,38]],[[2,0,37,2],[18,0,37,9],[30,0,37,33],[36,0,37,21],[48,0,37,55],[52,0,37,45],[64,0,37,64]],[[4,0,38,4],[11,0,38,11],[18,0,38,19],[35,0,38,35],[47,0,38,47],[57,0,38,57],[64,0,38,77]],[],[[2,0,49,2],[18,0,49,9],[34,0,49,37],[40,0,49,25],[52,0,49,59],[56,0,49,49],[66,0,49,77],[72,0,49,67],[84,0,49,90]],[[4,0,50,26],[8,0,50,10],[24,0,50,26],[28,0,50,30]],[[4,0,51,24],[8,0,51,10],[22,0,51,24],[26,0,51,28]],[[4,0,53,4],[12,0,53,11],[26,0,53,11],[29,0,53,28]],[[4,0,54,4],[12,0,54,11],[24,0,54,11],[27,0,54,26]],[[4,0,55,4],[12,0,55,11],[21,0,55,11],[24,0,55,23]],[[4,0,56,4],[11,0,56,11],[18,0,56,19],[40,0,56,40],[50,0,56,11],[52,0,56,52],[63,0,56,11],[65,0,56,65]],[],[[2,0,65,2],[18,0,65,9],[36,0,65,35],[42,0,65,27],[52,0,65,43]],[[4,0,66,4],[11,0,66,11],[17,0,66,18],[27,0,66,11],[29,0,66,29],[33,0,67,8],[40,0,67,16],[57,0,67,32],[63,0,67,39],[76,0,67,51],[82,0,67,58],[93,0,67,68],[99,0,67,75],[112,0,68,21]],[],[[2,0,77,2],[18,0,77,9],[29,0,77,29],[34,0,77,20],[45,0,77,36]],[[4,0,78,4],[12,0,78,11],[16,0,78,15],[23,0,78,23],[36,0,78,11],[39,0,78,38]],[[4,0,79,4],[12,0,79,11],[16,0,79,15],[23,0,79,23],[36,0,79,11],[39,0,79,38]],[[4,0,80,4],[12,0,81,6],[19,0,81,14],[31,0,81,6],[33,0,82,6],[41,0,82,15],[61,0,82,34],[68,0,82,42],[86,0,81,6],[88,0,83,6],[95,0,83,14],[107,0,81,6],[109,0,84,6],[117,0,84,15],[137,0,84,34],[144,0,84,42]],[],[[2,0,94,2],[18,0,94,9],[38,0,94,35],[44,0,94,29],[52,0,94,48]],[[4,0,95,19],[10,0,95,10],[19,0,95,32],[25,0,95,19],[27,0,95,40],[32,0,95,56],[36,0,95,60],[43,0,95,19],[45,0,95,69]],[[4,0,96,4],[11,0,96,11],[18,0,96,19],[40,0,28,38],[43,0,96,11],[45,0,96,61],[52,0,96,68],[60,0,96,11],[62,0,96,78],[69,0,96,98]],[],[[2,0,105,2],[18,0,105,9],[35,0,105,32],[45,0,105,26],[53,0,105,39]],[[4,0,106,4],[12,0,107,19],[18,0,107,26],[26,0,107,6],[28,0,108,19],[34,0,108,26],[46,0,107,6],[48,0,109,6],[53,0,109,22],[57,0,107,6],[59,0,110,6],[64,0,107,6],[66,0,111,19],[72,0,111,26],[88,0,107,6],[90,0,112,19],[96,0,112,26]],[],[[2,0,123,2],[18,0,123,9],[35,0,123,34],[39,0,123,26],[47,0,123,48],[57,0,123,42],[65,0,123,55]],[[4,0,124,4],[11,0,124,11],[18,0,124,19],[35,0,124,35],[42,0,124,42],[49,0,124,50],[67,0,124,67],[75,0,124,75],[83,0,124,83],[90,0,124,103]],[],[[2,0,133,2],[18,0,133,9],[38,0,133,35],[44,0,133,29],[52,0,133,48]],[[4,0,134,4],[11,0,134,24],[17,0,134,31],[27,0,134,11],[29,0,134,56],[35,0,134,63],[46,0,134,11],[48,0,134,76],[56,0,134,85],[66,0,134,94]],[],[[2,0,143,2],[18,0,143,9],[39,0,143,33],[43,0,143,30],[48,0,143,42]],[[4,0,144,4],[11,0,144,11],[19,0,144,20],[39,0,144,39]],[],[[2,0,153,2],[18,0,153,9],[39,0,153,34],[45,0,153,30],[51,0,153,47]],[[4,0,154,4],[12,0,154,11],[16,0,154,15],[20,0,154,11],[23,0,154,22]],[[4,0,155,4],[11,0,155,11],[19,0,155,20],[35,0,155,35]],[],[]]
|
|
@@ -13,7 +13,7 @@ library TxUtils {
|
|
|
13
13
|
require(scriptHashLen == 32);
|
|
14
14
|
require(dataHashLen == 32);
|
|
15
15
|
require(satoshis >= 0);
|
|
16
|
-
return
|
|
16
|
+
return TxUtils.satoshisToByteString(satoshis) + scriptHash + dataHash;
|
|
17
17
|
}
|
|
18
18
|
static function buildChangeOutput(TxOut change) : bytes {
|
|
19
19
|
return change.satoshis > 0 ? TxUtils.buildDataOutput(change.scriptHash, change.satoshis, change.dataHash) : b'';
|
|
@@ -30,8 +30,8 @@ library TxUtils {
|
|
|
30
30
|
static function buildP2PKHScript(Ripemd160 addr) : bytes {
|
|
31
31
|
return (OpCode.OP_DUP + OpCode.OP_HASH160 + pack(20) + addr + OpCode.OP_EQUALVERIFY + OpCode.OP_CHECKSIG);
|
|
32
32
|
}
|
|
33
|
-
static function buildP2PKHOutput(int amount, Ripemd160 addr
|
|
34
|
-
return TxUtils.buildDataOutput(sha256(TxUtils.buildP2PKHScript(addr)), amount,
|
|
33
|
+
static function buildP2PKHOutput(int amount, Ripemd160 addr) : bytes {
|
|
34
|
+
return TxUtils.buildDataOutput(sha256(TxUtils.buildP2PKHScript(addr)), amount, sha256(b''));
|
|
35
35
|
}
|
|
36
36
|
static function buildOpreturnScript(bytes data) : bytes {
|
|
37
37
|
return OpCode.OP_FALSE + OpCode.OP_RETURN + StdUtils.pushData(data);
|
|
@@ -39,4 +39,8 @@ library TxUtils {
|
|
|
39
39
|
static function satoshisToByteString(int n) : bytes {
|
|
40
40
|
return StdUtils.uint64ToByteString(n);
|
|
41
41
|
}
|
|
42
|
+
static function byteStringToSatoshis(bytes bs) : int {
|
|
43
|
+
require(len(bs) == 8);
|
|
44
|
+
return StdUtils.fromLEUnsigned(bs);
|
|
45
|
+
}
|
|
42
46
|
}
|
|
@@ -4,17 +4,17 @@ import "stdUtils.scrypt";
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
library
|
|
8
|
-
static function getTxHashFromTxHashPreimage(
|
|
7
|
+
library _opcat_labs_scrypt_ts_opcat_1_0_2__rs__TxHashPreimageUtils {
|
|
8
|
+
static function getTxHashFromTxHashPreimage(_opcat_labs_scrypt_ts_opcat_1_0_2__rs__TxHashPreimage txHashPreimage) : bytes {
|
|
9
9
|
require(len(txHashPreimage.version) == 4);
|
|
10
|
-
int inputCount =
|
|
11
|
-
int outputCount =
|
|
12
|
-
return hash256(txHashPreimage.version +
|
|
10
|
+
int inputCount = _opcat_labs_scrypt_ts_opcat_1_0_2__rs__StdUtils.checkLenDivisibleBy(txHashPreimage.inputList, 72);
|
|
11
|
+
int outputCount = _opcat_labs_scrypt_ts_opcat_1_0_2__rs__StdUtils.checkLenDivisibleBy(txHashPreimage.outputList, 72);
|
|
12
|
+
return hash256(txHashPreimage.version + _opcat_labs_scrypt_ts_opcat_1_0_2__rs__StdUtils.writeVarInt(inputCount) + txHashPreimage.inputList + _opcat_labs_scrypt_ts_opcat_1_0_2__rs__StdUtils.writeVarInt(outputCount) + txHashPreimage.outputList + txHashPreimage.nLockTime);
|
|
13
13
|
}
|
|
14
|
-
static function getInputByteString(
|
|
14
|
+
static function getInputByteString(_opcat_labs_scrypt_ts_opcat_1_0_2__rs__TxHashPreimage txHashPreimage, int inputIndex) : bytes {
|
|
15
15
|
return txHashPreimage.inputList[inputIndex * 72 : (inputIndex + 1) * 72];
|
|
16
16
|
}
|
|
17
|
-
static function getOutputByteString(
|
|
17
|
+
static function getOutputByteString(_opcat_labs_scrypt_ts_opcat_1_0_2__rs__TxHashPreimage txHashPreimage, int outputIndex) : bytes {
|
|
18
18
|
return txHashPreimage.outputList[outputIndex * 72 : (outputIndex + 1) * 72];
|
|
19
19
|
}
|
|
20
20
|
}
|