@bsv/sdk 1.3.12 → 1.3.13
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/dist/cjs/mod.js +15 -15
- package/dist/cjs/mod.js.map +1 -1
- package/dist/cjs/package.json +10 -2
- package/dist/cjs/src/auth/Peer.js +62 -46
- package/dist/cjs/src/auth/Peer.js.map +1 -1
- package/dist/cjs/src/auth/SessionManager.js +4 -4
- package/dist/cjs/src/auth/SessionManager.js.map +1 -1
- package/dist/cjs/src/auth/__tests/Peer.test.js +446 -0
- package/dist/cjs/src/auth/__tests/Peer.test.js.map +1 -0
- package/dist/cjs/src/auth/__tests/SessionManager.test.js +69 -0
- package/dist/cjs/src/auth/__tests/SessionManager.test.js.map +1 -0
- package/dist/cjs/src/auth/certificates/Certificate.js +26 -23
- package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/MasterCertificate.js +18 -16
- package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +7 -7
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/__tests/Certificate.test.js +182 -0
- package/dist/cjs/src/auth/certificates/__tests/Certificate.test.js.map +1 -0
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js +22 -22
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/cjs/src/auth/certificates/__tests/MasterCertificate.test.js +184 -0
- package/dist/cjs/src/auth/certificates/__tests/MasterCertificate.test.js.map +1 -0
- package/dist/cjs/src/auth/certificates/__tests/VerifiableCertificate.test.js +75 -0
- package/dist/cjs/src/auth/certificates/__tests/VerifiableCertificate.test.js.map +1 -0
- package/dist/cjs/src/auth/certificates/index.js +5 -5
- package/dist/cjs/src/auth/certificates/index.js.map +1 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js +74 -64
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/src/auth/clients/index.js +1 -1
- package/dist/cjs/src/auth/clients/index.js.map +1 -1
- package/dist/cjs/src/auth/index.js +7 -7
- package/dist/cjs/src/auth/index.js.map +1 -1
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +62 -54
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/cjs/src/auth/transports/index.js +1 -1
- package/dist/cjs/src/auth/transports/index.js.map +1 -1
- package/dist/cjs/src/auth/utils/__tests/cryptononce.test.js +101 -0
- package/dist/cjs/src/auth/utils/__tests/cryptononce.test.js.map +1 -0
- package/dist/cjs/src/auth/utils/__tests/getVerifiableCertificates.test.js +106 -0
- package/dist/cjs/src/auth/utils/__tests/getVerifiableCertificates.test.js.map +1 -0
- package/dist/cjs/src/auth/utils/__tests/validateCertificates.test.js +111 -0
- package/dist/cjs/src/auth/utils/__tests/validateCertificates.test.js.map +1 -0
- package/dist/cjs/src/auth/utils/createNonce.js +4 -4
- package/dist/cjs/src/auth/utils/createNonce.js.map +1 -1
- package/dist/cjs/src/auth/utils/getVerifiableCertificates.js +2 -2
- package/dist/cjs/src/auth/utils/getVerifiableCertificates.js.map +1 -1
- package/dist/cjs/src/auth/utils/index.js +4 -4
- package/dist/cjs/src/auth/utils/index.js.map +1 -1
- package/dist/cjs/src/auth/utils/validateCertificates.js +2 -2
- package/dist/cjs/src/auth/utils/validateCertificates.js.map +1 -1
- package/dist/cjs/src/auth/utils/verifyNonce.js +3 -3
- package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/cjs/src/compat/BSM.js +9 -9
- package/dist/cjs/src/compat/BSM.js.map +1 -1
- package/dist/cjs/src/compat/ECIES.js +157 -116
- package/dist/cjs/src/compat/ECIES.js.map +1 -1
- package/dist/cjs/src/compat/HD.js +75 -75
- package/dist/cjs/src/compat/HD.js.map +1 -1
- package/dist/cjs/src/compat/Mnemonic.js +98 -93
- package/dist/cjs/src/compat/Mnemonic.js.map +1 -1
- package/dist/cjs/src/compat/Utxo.js +5 -5
- package/dist/cjs/src/compat/Utxo.js.map +1 -1
- package/dist/cjs/src/compat/__tests/BSM.test.js +69 -0
- package/dist/cjs/src/compat/__tests/BSM.test.js.map +1 -0
- package/dist/cjs/src/compat/__tests/ECIES.test.js +115 -0
- package/dist/cjs/src/compat/__tests/ECIES.test.js.map +1 -0
- package/dist/cjs/src/compat/__tests/HD.test.js +336 -0
- package/dist/cjs/src/compat/__tests/HD.test.js.map +1 -0
- package/dist/cjs/src/compat/__tests/Mnemonic.test.js +150 -0
- package/dist/cjs/src/compat/__tests/Mnemonic.test.js.map +1 -0
- package/dist/cjs/src/compat/__tests/Mnemonic.vectors.js +175 -0
- package/dist/cjs/src/compat/__tests/Mnemonic.vectors.js.map +1 -0
- package/dist/cjs/src/compat/index.js +9 -9
- package/dist/cjs/src/compat/index.js.map +1 -1
- package/dist/cjs/src/messages/EncryptedMessage.js +17 -15
- package/dist/cjs/src/messages/EncryptedMessage.js.map +1 -1
- package/dist/cjs/src/messages/SignedMessage.js +20 -20
- package/dist/cjs/src/messages/SignedMessage.js.map +1 -1
- package/dist/cjs/src/messages/__tests/EncryptedMessage.test.js +57 -0
- package/dist/cjs/src/messages/__tests/EncryptedMessage.test.js.map +1 -0
- package/dist/cjs/src/messages/__tests/SignedMessage.test.js +52 -0
- package/dist/cjs/src/messages/__tests/SignedMessage.test.js.map +1 -0
- package/dist/cjs/src/messages/index.js +2 -2
- package/dist/cjs/src/messages/index.js.map +1 -1
- package/dist/cjs/src/overlay-tools/LookupResolver.js +20 -13
- package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js +44 -32
- package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js +41 -30
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/cjs/src/overlay-tools/__tests/LookupResolver.test.js +1471 -0
- package/dist/cjs/src/overlay-tools/__tests/LookupResolver.test.js.map +1 -0
- package/dist/cjs/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.js +78 -0
- package/dist/cjs/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.js.map +1 -0
- package/dist/cjs/src/overlay-tools/__tests/SHIPBroadcaster.test.js +933 -0
- package/dist/cjs/src/overlay-tools/__tests/SHIPBroadcaster.test.js.map +1 -0
- package/dist/cjs/src/overlay-tools/index.js +8 -8
- package/dist/cjs/src/overlay-tools/index.js.map +1 -1
- package/dist/cjs/src/primitives/BasePoint.js +2 -2
- package/dist/cjs/src/primitives/BasePoint.js.map +1 -1
- package/dist/cjs/src/primitives/BigNumber.js +46 -59
- package/dist/cjs/src/primitives/BigNumber.js.map +1 -1
- package/dist/cjs/src/primitives/Curve.js +29 -39
- package/dist/cjs/src/primitives/Curve.js.map +1 -1
- package/dist/cjs/src/primitives/DRBG.js +8 -14
- package/dist/cjs/src/primitives/DRBG.js.map +1 -1
- package/dist/cjs/src/primitives/ECDSA.js +24 -24
- package/dist/cjs/src/primitives/ECDSA.js.map +1 -1
- package/dist/cjs/src/primitives/Hash.js +76 -111
- package/dist/cjs/src/primitives/Hash.js.map +1 -1
- package/dist/cjs/src/primitives/JacobianPoint.js +20 -16
- package/dist/cjs/src/primitives/JacobianPoint.js.map +1 -1
- package/dist/cjs/src/primitives/K256.js +2 -2
- package/dist/cjs/src/primitives/K256.js.map +1 -1
- package/dist/cjs/src/primitives/Mersenne.js +4 -4
- package/dist/cjs/src/primitives/Mersenne.js.map +1 -1
- package/dist/cjs/src/primitives/MontgomoryMethod.js +5 -5
- package/dist/cjs/src/primitives/MontgomoryMethod.js.map +1 -1
- package/dist/cjs/src/primitives/Point.js +74 -72
- package/dist/cjs/src/primitives/Point.js.map +1 -1
- package/dist/cjs/src/primitives/Polynomial.js +15 -13
- package/dist/cjs/src/primitives/Polynomial.js.map +1 -1
- package/dist/cjs/src/primitives/PrivateKey.js +48 -39
- package/dist/cjs/src/primitives/PrivateKey.js.map +1 -1
- package/dist/cjs/src/primitives/PublicKey.js +23 -23
- package/dist/cjs/src/primitives/PublicKey.js.map +1 -1
- package/dist/cjs/src/primitives/Random.js +4 -4
- package/dist/cjs/src/primitives/Random.js.map +1 -1
- package/dist/cjs/src/primitives/ReductionContext.js +11 -11
- package/dist/cjs/src/primitives/ReductionContext.js.map +1 -1
- package/dist/cjs/src/primitives/Schnorr.js +29 -23
- package/dist/cjs/src/primitives/Schnorr.js.map +1 -1
- package/dist/cjs/src/primitives/Signature.js +25 -24
- package/dist/cjs/src/primitives/Signature.js.map +1 -1
- package/dist/cjs/src/primitives/SymmetricKey.js +26 -26
- package/dist/cjs/src/primitives/SymmetricKey.js.map +1 -1
- package/dist/cjs/src/primitives/TransactionSignature.js +23 -21
- package/dist/cjs/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/cjs/src/primitives/__tests/AESGCM.test.js +248 -0
- package/dist/cjs/src/primitives/__tests/AESGCM.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/BRC42.private.vectors.js +36 -0
- package/dist/cjs/src/primitives/__tests/BRC42.private.vectors.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/BRC42.public.vectors.js +36 -0
- package/dist/cjs/src/primitives/__tests/BRC42.public.vectors.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.arithmatic.test.js +501 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.arithmatic.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.binary.test.js +185 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.binary.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.constructor.test.js +149 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.constructor.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.dhGroup.test.js +23 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.dhGroup.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.fixtures.js +268 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.fixtures.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.serializers.test.js +147 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.serializers.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.utils.test.js +322 -0
- package/dist/cjs/src/primitives/__tests/BigNumber.utils.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/Curve.unit.test.js +145 -0
- package/dist/cjs/src/primitives/__tests/Curve.unit.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/DRBG.test.js +22 -0
- package/dist/cjs/src/primitives/__tests/DRBG.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/DRBG.vectors.js +170 -0
- package/dist/cjs/src/primitives/__tests/DRBG.vectors.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/ECDH.test.js +34 -0
- package/dist/cjs/src/primitives/__tests/ECDH.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/ECDSA.test.js +89 -0
- package/dist/cjs/src/primitives/__tests/ECDSA.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/HMAC.test.js +60 -0
- package/dist/cjs/src/primitives/__tests/HMAC.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/Hash.test.js +159 -0
- package/dist/cjs/src/primitives/__tests/Hash.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/PBKDF2.vectors.js +122 -0
- package/dist/cjs/src/primitives/__tests/PBKDF2.vectors.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/PrivateKey.split.test.js +105 -0
- package/dist/cjs/src/primitives/__tests/PrivateKey.split.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/PrivateKey.test.js +90 -0
- package/dist/cjs/src/primitives/__tests/PrivateKey.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/PublicKey.test.js +83 -0
- package/dist/cjs/src/primitives/__tests/PublicKey.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/Random.test.js +19 -0
- package/dist/cjs/src/primitives/__tests/Random.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/Reader.test.js +282 -0
- package/dist/cjs/src/primitives/__tests/Reader.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/ReductionContext.test.js +224 -0
- package/dist/cjs/src/primitives/__tests/ReductionContext.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/Schnorr.test.js +213 -0
- package/dist/cjs/src/primitives/__tests/Schnorr.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/SymmetricKey.test.js +51 -0
- package/dist/cjs/src/primitives/__tests/SymmetricKey.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/SymmetricKey.vectors.js +43 -0
- package/dist/cjs/src/primitives/__tests/SymmetricKey.vectors.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/Writer.test.js +176 -0
- package/dist/cjs/src/primitives/__tests/Writer.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/bug-31.test.js +32 -0
- package/dist/cjs/src/primitives/__tests/bug-31.test.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/sighash.vectors.js +3506 -0
- package/dist/cjs/src/primitives/__tests/sighash.vectors.js.map +1 -0
- package/dist/cjs/src/primitives/__tests/utils.test.js +110 -0
- package/dist/cjs/src/primitives/__tests/utils.test.js.map +1 -0
- package/dist/cjs/src/primitives/index.js +27 -27
- package/dist/cjs/src/primitives/index.js.map +1 -1
- package/dist/cjs/src/primitives/utils.js +70 -60
- package/dist/cjs/src/primitives/utils.js.map +1 -1
- package/dist/cjs/src/script/LockingScript.js +2 -2
- package/dist/cjs/src/script/LockingScript.js.map +1 -1
- package/dist/cjs/src/script/Script.js +49 -47
- package/dist/cjs/src/script/Script.js.map +1 -1
- package/dist/cjs/src/script/Spend.js +305 -300
- package/dist/cjs/src/script/Spend.js.map +1 -1
- package/dist/cjs/src/script/UnlockingScript.js +2 -2
- package/dist/cjs/src/script/UnlockingScript.js.map +1 -1
- package/dist/cjs/src/script/__tests/Script.test.js +347 -0
- package/dist/cjs/src/script/__tests/Script.test.js.map +1 -0
- package/dist/cjs/src/script/__tests/Spend.test.js +282 -0
- package/dist/cjs/src/script/__tests/Spend.test.js.map +1 -0
- package/dist/cjs/src/script/__tests/SpendComplex.test.js +52 -0
- package/dist/cjs/src/script/__tests/SpendComplex.test.js.map +1 -0
- package/dist/cjs/src/script/__tests/script.invalid.vectors.js +2370 -0
- package/dist/cjs/src/script/__tests/script.invalid.vectors.js.map +1 -0
- package/dist/cjs/src/script/__tests/script.valid.vectors.js +1181 -0
- package/dist/cjs/src/script/__tests/script.valid.vectors.js.map +1 -0
- package/dist/cjs/src/script/__tests/spend.valid.vectors.js +2298 -0
- package/dist/cjs/src/script/__tests/spend.valid.vectors.js.map +1 -0
- package/dist/cjs/src/script/index.js +11 -11
- package/dist/cjs/src/script/index.js.map +1 -1
- package/dist/cjs/src/script/templates/P2PKH.js +40 -36
- package/dist/cjs/src/script/templates/P2PKH.js.map +1 -1
- package/dist/cjs/src/script/templates/PushDrop.js +42 -43
- package/dist/cjs/src/script/templates/PushDrop.js.map +1 -1
- package/dist/cjs/src/script/templates/RPuzzle.js +48 -45
- package/dist/cjs/src/script/templates/RPuzzle.js.map +1 -1
- package/dist/cjs/src/script/templates/__tests/PushDrop.test.js +161 -0
- package/dist/cjs/src/script/templates/__tests/PushDrop.test.js.map +1 -0
- package/dist/cjs/src/script/templates/index.js +6 -6
- package/dist/cjs/src/script/templates/index.js.map +1 -1
- package/dist/cjs/src/totp/__tests/totp.test.js +67 -0
- package/dist/cjs/src/totp/__tests/totp.test.js.map +1 -0
- package/dist/cjs/src/totp/index.js +1 -1
- package/dist/cjs/src/totp/index.js.map +1 -1
- package/dist/cjs/src/totp/totp.js +7 -7
- package/dist/cjs/src/totp/totp.js.map +1 -1
- package/dist/cjs/src/transaction/Beef.js +141 -129
- package/dist/cjs/src/transaction/Beef.js.map +1 -1
- package/dist/cjs/src/transaction/BeefParty.js +25 -25
- package/dist/cjs/src/transaction/BeefParty.js.map +1 -1
- package/dist/cjs/src/transaction/BeefTx.js +25 -23
- package/dist/cjs/src/transaction/BeefTx.js.map +1 -1
- package/dist/cjs/src/transaction/Broadcaster.js.map +1 -1
- package/dist/cjs/src/transaction/MerklePath.js +27 -22
- package/dist/cjs/src/transaction/MerklePath.js.map +1 -1
- package/dist/cjs/src/transaction/Transaction.js +89 -157
- package/dist/cjs/src/transaction/Transaction.js.map +1 -1
- package/dist/cjs/src/transaction/__tests/Beef.test.js +393 -0
- package/dist/cjs/src/transaction/__tests/Beef.test.js.map +1 -0
- package/dist/cjs/src/transaction/__tests/MerklePath.test.js +209 -0
- package/dist/cjs/src/transaction/__tests/MerklePath.test.js.map +1 -0
- package/dist/cjs/src/transaction/__tests/Transaction.benchmarks.test.js +219 -0
- package/dist/cjs/src/transaction/__tests/Transaction.benchmarks.test.js.map +1 -0
- package/dist/cjs/src/transaction/__tests/Transaction.test.js +1073 -0
- package/dist/cjs/src/transaction/__tests/Transaction.test.js.map +1 -0
- package/dist/cjs/src/transaction/__tests/bigtx.vectors.js +7 -0
- package/dist/cjs/src/transaction/__tests/bigtx.vectors.js.map +1 -0
- package/dist/cjs/src/transaction/__tests/bump.invalid.vectors.js +11 -0
- package/dist/cjs/src/transaction/__tests/bump.invalid.vectors.js.map +1 -0
- package/dist/cjs/src/transaction/__tests/bump.valid.vectors.js +7 -0
- package/dist/cjs/src/transaction/__tests/bump.valid.vectors.js.map +1 -0
- package/dist/cjs/src/transaction/__tests/tx.invalid.vectors.js +230 -0
- package/dist/cjs/src/transaction/__tests/tx.invalid.vectors.js.map +1 -0
- package/dist/cjs/src/transaction/__tests/tx.valid.vectors.js +296 -0
- package/dist/cjs/src/transaction/__tests/tx.valid.vectors.js.map +1 -0
- package/dist/cjs/src/transaction/broadcasters/ARC.js +39 -35
- package/dist/cjs/src/transaction/broadcasters/ARC.js.map +1 -1
- package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js +2 -2
- package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
- package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js +15 -15
- package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
- package/dist/cjs/src/transaction/broadcasters/__tests/ARC.test.js +246 -0
- package/dist/cjs/src/transaction/broadcasters/__tests/ARC.test.js.map +1 -0
- package/dist/cjs/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.js +148 -0
- package/dist/cjs/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.js.map +1 -0
- package/dist/cjs/src/transaction/broadcasters/index.js +6 -6
- package/dist/cjs/src/transaction/broadcasters/index.js.map +1 -1
- package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js +2 -2
- package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -1
- package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js +8 -8
- package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
- package/dist/cjs/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.js +155 -0
- package/dist/cjs/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.js.map +1 -0
- package/dist/cjs/src/transaction/chaintrackers/index.js +4 -4
- package/dist/cjs/src/transaction/chaintrackers/index.js.map +1 -1
- package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js +3 -3
- package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
- package/dist/cjs/src/transaction/fee-models/index.js +2 -2
- package/dist/cjs/src/transaction/fee-models/index.js.map +1 -1
- package/dist/cjs/src/transaction/http/DefaultHttpClient.js +11 -11
- package/dist/cjs/src/transaction/http/DefaultHttpClient.js.map +1 -1
- package/dist/cjs/src/transaction/http/FetchHttpClient.js +4 -2
- package/dist/cjs/src/transaction/http/FetchHttpClient.js.map +1 -1
- package/dist/cjs/src/transaction/http/NodejsHttpClient.js +10 -8
- package/dist/cjs/src/transaction/http/NodejsHttpClient.js.map +1 -1
- package/dist/cjs/src/transaction/http/index.js +6 -6
- package/dist/cjs/src/transaction/http/index.js.map +1 -1
- package/dist/cjs/src/transaction/index.js +12 -12
- package/dist/cjs/src/transaction/index.js.map +1 -1
- package/dist/cjs/src/wallet/CachedKeyDeriver.js +65 -63
- package/dist/cjs/src/wallet/CachedKeyDeriver.js.map +1 -1
- package/dist/cjs/src/wallet/KeyDeriver.js +66 -58
- package/dist/cjs/src/wallet/KeyDeriver.js.map +1 -1
- package/dist/cjs/src/wallet/ProtoWallet.js +27 -14
- package/dist/cjs/src/wallet/ProtoWallet.js.map +1 -1
- package/dist/cjs/src/wallet/WalletClient.js +15 -14
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/src/wallet/__tests/CachedKeyDeriver.test.js +269 -0
- package/dist/cjs/src/wallet/__tests/CachedKeyDeriver.test.js.map +1 -0
- package/dist/cjs/src/wallet/__tests/KeyDeriver.test.js +114 -0
- package/dist/cjs/src/wallet/__tests/KeyDeriver.test.js.map +1 -0
- package/dist/cjs/src/wallet/__tests/ProtoWallet.test.js +475 -0
- package/dist/cjs/src/wallet/__tests/ProtoWallet.test.js.map +1 -0
- package/dist/cjs/src/wallet/index.js +12 -12
- package/dist/cjs/src/wallet/index.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +3 -3
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js +10 -10
- package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireCalls.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +1293 -1316
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +320 -272
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/XDM.js +8 -5
- package/dist/cjs/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/__tests/WalletWire.integration.test.js +1962 -0
- package/dist/cjs/src/wallet/substrates/__tests/WalletWire.integration.test.js.map +1 -0
- package/dist/cjs/src/wallet/substrates/__tests/XDM.test.js +579 -0
- package/dist/cjs/src/wallet/substrates/__tests/XDM.test.js.map +1 -0
- package/dist/cjs/src/wallet/substrates/index.js +12 -12
- package/dist/cjs/src/wallet/substrates/index.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/window.CWI.js +4 -4
- package/dist/cjs/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/mod.js +31 -15
- package/dist/esm/mod.js.map +1 -1
- package/dist/esm/src/auth/Peer.js +67 -47
- package/dist/esm/src/auth/Peer.js.map +1 -1
- package/dist/esm/src/auth/SessionManager.js +9 -5
- package/dist/esm/src/auth/SessionManager.js.map +1 -1
- package/dist/esm/src/auth/__tests/Peer.test.js +448 -0
- package/dist/esm/src/auth/__tests/Peer.test.js.map +1 -0
- package/dist/esm/src/auth/__tests/SessionManager.test.js +69 -0
- package/dist/esm/src/auth/__tests/SessionManager.test.js.map +1 -0
- package/dist/esm/src/auth/certificates/Certificate.js +31 -25
- package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js +25 -16
- package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js +14 -7
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/__tests/Certificate.test.js +182 -0
- package/dist/esm/src/auth/certificates/__tests/Certificate.test.js.map +1 -0
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js +26 -22
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/esm/src/auth/certificates/__tests/MasterCertificate.test.js +184 -0
- package/dist/esm/src/auth/certificates/__tests/MasterCertificate.test.js.map +1 -0
- package/dist/esm/src/auth/certificates/__tests/VerifiableCertificate.test.js +75 -0
- package/dist/esm/src/auth/certificates/__tests/VerifiableCertificate.test.js.map +1 -0
- package/dist/esm/src/auth/certificates/index.js +25 -4
- package/dist/esm/src/auth/certificates/index.js.map +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js +79 -65
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/src/auth/clients/index.js +17 -1
- package/dist/esm/src/auth/clients/index.js.map +1 -1
- package/dist/esm/src/auth/index.js +23 -7
- package/dist/esm/src/auth/index.js.map +1 -1
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +67 -55
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/esm/src/auth/transports/index.js +17 -1
- package/dist/esm/src/auth/transports/index.js.map +1 -1
- package/dist/esm/src/auth/types.js +2 -1
- package/dist/esm/src/auth/utils/__tests/cryptononce.test.js +101 -0
- package/dist/esm/src/auth/utils/__tests/cryptononce.test.js.map +1 -0
- package/dist/esm/src/auth/utils/__tests/getVerifiableCertificates.test.js +106 -0
- package/dist/esm/src/auth/utils/__tests/getVerifiableCertificates.test.js.map +1 -0
- package/dist/esm/src/auth/utils/__tests/validateCertificates.test.js +111 -0
- package/dist/esm/src/auth/utils/__tests/validateCertificates.test.js.map +1 -0
- package/dist/esm/src/auth/utils/createNonce.js +8 -5
- package/dist/esm/src/auth/utils/createNonce.js.map +1 -1
- package/dist/esm/src/auth/utils/getVerifiableCertificates.js +7 -3
- package/dist/esm/src/auth/utils/getVerifiableCertificates.js.map +1 -1
- package/dist/esm/src/auth/utils/index.js +20 -4
- package/dist/esm/src/auth/utils/index.js.map +1 -1
- package/dist/esm/src/auth/utils/validateCertificates.js +7 -3
- package/dist/esm/src/auth/utils/validateCertificates.js.map +1 -1
- package/dist/esm/src/auth/utils/verifyNonce.js +7 -4
- package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/esm/src/compat/BSM.js +56 -14
- package/dist/esm/src/compat/BSM.js.map +1 -1
- package/dist/esm/src/compat/ECIES.js +197 -117
- package/dist/esm/src/compat/ECIES.js.map +1 -1
- package/dist/esm/src/compat/HD.js +115 -76
- package/dist/esm/src/compat/HD.js.map +1 -1
- package/dist/esm/src/compat/Mnemonic.js +138 -94
- package/dist/esm/src/compat/Mnemonic.js.map +1 -1
- package/dist/esm/src/compat/Utxo.js +12 -6
- package/dist/esm/src/compat/Utxo.js.map +1 -1
- package/dist/esm/src/compat/__tests/BSM.test.js +69 -0
- package/dist/esm/src/compat/__tests/BSM.test.js.map +1 -0
- package/dist/esm/src/compat/__tests/ECIES.test.js +115 -0
- package/dist/esm/src/compat/__tests/ECIES.test.js.map +1 -0
- package/dist/esm/src/compat/__tests/HD.test.js +336 -0
- package/dist/esm/src/compat/__tests/HD.test.js.map +1 -0
- package/dist/esm/src/compat/__tests/Mnemonic.test.js +150 -0
- package/dist/esm/src/compat/__tests/Mnemonic.test.js.map +1 -0
- package/dist/esm/src/compat/__tests/Mnemonic.vectors.js +175 -0
- package/dist/esm/src/compat/__tests/Mnemonic.vectors.js.map +1 -0
- package/dist/esm/src/compat/bip-39-wordlist-en.js +4 -1
- package/dist/esm/src/compat/bip-39-wordlist-en.js.map +1 -1
- package/dist/esm/src/compat/index.js +48 -5
- package/dist/esm/src/compat/index.js.map +1 -1
- package/dist/esm/src/messages/EncryptedMessage.js +27 -17
- package/dist/esm/src/messages/EncryptedMessage.js.map +1 -1
- package/dist/esm/src/messages/SignedMessage.js +30 -22
- package/dist/esm/src/messages/SignedMessage.js.map +1 -1
- package/dist/esm/src/messages/__tests/EncryptedMessage.test.js +57 -0
- package/dist/esm/src/messages/__tests/EncryptedMessage.test.js.map +1 -0
- package/dist/esm/src/messages/__tests/SignedMessage.test.js +52 -0
- package/dist/esm/src/messages/__tests/SignedMessage.test.js.map +1 -0
- package/dist/esm/src/messages/index.js +38 -2
- package/dist/esm/src/messages/index.js.map +1 -1
- package/dist/esm/src/overlay-tools/LookupResolver.js +32 -17
- package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js +51 -33
- package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js +51 -32
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/esm/src/overlay-tools/__tests/LookupResolver.test.js +1471 -0
- package/dist/esm/src/overlay-tools/__tests/LookupResolver.test.js.map +1 -0
- package/dist/esm/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.js +78 -0
- package/dist/esm/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.js.map +1 -0
- package/dist/esm/src/overlay-tools/__tests/SHIPBroadcaster.test.js +933 -0
- package/dist/esm/src/overlay-tools/__tests/SHIPBroadcaster.test.js.map +1 -0
- package/dist/esm/src/overlay-tools/index.js +28 -5
- package/dist/esm/src/overlay-tools/index.js.map +1 -1
- package/dist/esm/src/primitives/AESGCM.js +39 -26
- package/dist/esm/src/primitives/AESGCM.js.map +1 -1
- package/dist/esm/src/primitives/BasePoint.js +9 -3
- package/dist/esm/src/primitives/BasePoint.js.map +1 -1
- package/dist/esm/src/primitives/BigNumber.js +50 -60
- package/dist/esm/src/primitives/BigNumber.js.map +1 -1
- package/dist/esm/src/primitives/Curve.js +36 -40
- package/dist/esm/src/primitives/Curve.js.map +1 -1
- package/dist/esm/src/primitives/DRBG.js +12 -15
- package/dist/esm/src/primitives/DRBG.js.map +1 -1
- package/dist/esm/src/primitives/ECDSA.js +34 -26
- package/dist/esm/src/primitives/ECDSA.js.map +1 -1
- package/dist/esm/src/primitives/Hash.js +115 -130
- package/dist/esm/src/primitives/Hash.js.map +1 -1
- package/dist/esm/src/primitives/JacobianPoint.js +26 -16
- package/dist/esm/src/primitives/JacobianPoint.js.map +1 -1
- package/dist/esm/src/primitives/K256.js +8 -2
- package/dist/esm/src/primitives/K256.js.map +1 -1
- package/dist/esm/src/primitives/Mersenne.js +11 -5
- package/dist/esm/src/primitives/Mersenne.js.map +1 -1
- package/dist/esm/src/primitives/MontgomoryMethod.js +11 -5
- package/dist/esm/src/primitives/MontgomoryMethod.js.map +1 -1
- package/dist/esm/src/primitives/Point.js +80 -72
- package/dist/esm/src/primitives/Point.js.map +1 -1
- package/dist/esm/src/primitives/Polynomial.js +25 -15
- package/dist/esm/src/primitives/Polynomial.js.map +1 -1
- package/dist/esm/src/primitives/PrivateKey.js +90 -40
- package/dist/esm/src/primitives/PrivateKey.js.map +1 -1
- package/dist/esm/src/primitives/PublicKey.js +29 -23
- package/dist/esm/src/primitives/PublicKey.js.map +1 -1
- package/dist/esm/src/primitives/Random.js +7 -5
- package/dist/esm/src/primitives/Random.js.map +1 -1
- package/dist/esm/src/primitives/ReductionContext.js +18 -12
- package/dist/esm/src/primitives/ReductionContext.js.map +1 -1
- package/dist/esm/src/primitives/Schnorr.js +36 -24
- package/dist/esm/src/primitives/Schnorr.js.map +1 -1
- package/dist/esm/src/primitives/Signature.js +32 -25
- package/dist/esm/src/primitives/Signature.js.map +1 -1
- package/dist/esm/src/primitives/SymmetricKey.js +32 -26
- package/dist/esm/src/primitives/SymmetricKey.js.map +1 -1
- package/dist/esm/src/primitives/TransactionSignature.js +62 -21
- package/dist/esm/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/esm/src/primitives/__tests/AESGCM.test.js +248 -0
- package/dist/esm/src/primitives/__tests/AESGCM.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/BRC42.private.vectors.js +36 -0
- package/dist/esm/src/primitives/__tests/BRC42.private.vectors.js.map +1 -0
- package/dist/esm/src/primitives/__tests/BRC42.public.vectors.js +36 -0
- package/dist/esm/src/primitives/__tests/BRC42.public.vectors.js.map +1 -0
- package/dist/esm/src/primitives/__tests/BigNumber.arithmatic.test.js +501 -0
- package/dist/esm/src/primitives/__tests/BigNumber.arithmatic.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/BigNumber.binary.test.js +185 -0
- package/dist/esm/src/primitives/__tests/BigNumber.binary.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/BigNumber.constructor.test.js +149 -0
- package/dist/esm/src/primitives/__tests/BigNumber.constructor.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/BigNumber.dhGroup.test.js +23 -0
- package/dist/esm/src/primitives/__tests/BigNumber.dhGroup.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/BigNumber.fixtures.js +268 -0
- package/dist/esm/src/primitives/__tests/BigNumber.fixtures.js.map +1 -0
- package/dist/esm/src/primitives/__tests/BigNumber.serializers.test.js +147 -0
- package/dist/esm/src/primitives/__tests/BigNumber.serializers.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/BigNumber.utils.test.js +322 -0
- package/dist/esm/src/primitives/__tests/BigNumber.utils.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/Curve.unit.test.js +145 -0
- package/dist/esm/src/primitives/__tests/Curve.unit.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/DRBG.test.js +22 -0
- package/dist/esm/src/primitives/__tests/DRBG.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/DRBG.vectors.js +170 -0
- package/dist/esm/src/primitives/__tests/DRBG.vectors.js.map +1 -0
- package/dist/esm/src/primitives/__tests/ECDH.test.js +34 -0
- package/dist/esm/src/primitives/__tests/ECDH.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/ECDSA.test.js +89 -0
- package/dist/esm/src/primitives/__tests/ECDSA.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/HMAC.test.js +60 -0
- package/dist/esm/src/primitives/__tests/HMAC.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/Hash.test.js +159 -0
- package/dist/esm/src/primitives/__tests/Hash.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/PBKDF2.vectors.js +122 -0
- package/dist/esm/src/primitives/__tests/PBKDF2.vectors.js.map +1 -0
- package/dist/esm/src/primitives/__tests/PrivateKey.split.test.js +105 -0
- package/dist/esm/src/primitives/__tests/PrivateKey.split.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/PrivateKey.test.js +90 -0
- package/dist/esm/src/primitives/__tests/PrivateKey.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/PublicKey.test.js +83 -0
- package/dist/esm/src/primitives/__tests/PublicKey.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/Random.test.js +19 -0
- package/dist/esm/src/primitives/__tests/Random.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/Reader.test.js +282 -0
- package/dist/esm/src/primitives/__tests/Reader.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/ReductionContext.test.js +223 -0
- package/dist/esm/src/primitives/__tests/ReductionContext.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/Schnorr.test.js +213 -0
- package/dist/esm/src/primitives/__tests/Schnorr.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/SymmetricKey.test.js +51 -0
- package/dist/esm/src/primitives/__tests/SymmetricKey.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/SymmetricKey.vectors.js +43 -0
- package/dist/esm/src/primitives/__tests/SymmetricKey.vectors.js.map +1 -0
- package/dist/esm/src/primitives/__tests/Writer.test.js +176 -0
- package/dist/esm/src/primitives/__tests/Writer.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/bug-31.test.js +32 -0
- package/dist/esm/src/primitives/__tests/bug-31.test.js.map +1 -0
- package/dist/esm/src/primitives/__tests/sighash.vectors.js +3506 -0
- package/dist/esm/src/primitives/__tests/sighash.vectors.js.map +1 -0
- package/dist/esm/src/primitives/__tests/utils.test.js +110 -0
- package/dist/esm/src/primitives/__tests/utils.test.js.map +1 -0
- package/dist/esm/src/primitives/index.js +66 -14
- package/dist/esm/src/primitives/index.js.map +1 -1
- package/dist/esm/src/primitives/utils.js +109 -80
- package/dist/esm/src/primitives/utils.js.map +1 -1
- package/dist/esm/src/script/LockingScript.js +8 -2
- package/dist/esm/src/script/LockingScript.js.map +1 -1
- package/dist/esm/src/script/OP.js +3 -1
- package/dist/esm/src/script/OP.js.map +1 -1
- package/dist/esm/src/script/Script.js +56 -48
- package/dist/esm/src/script/Script.js.map +1 -1
- package/dist/esm/src/script/ScriptChunk.js +2 -1
- package/dist/esm/src/script/ScriptTemplate.js +2 -1
- package/dist/esm/src/script/Spend.js +345 -301
- package/dist/esm/src/script/Spend.js.map +1 -1
- package/dist/esm/src/script/UnlockingScript.js +8 -2
- package/dist/esm/src/script/UnlockingScript.js.map +1 -1
- package/dist/esm/src/script/__tests/Script.test.js +347 -0
- package/dist/esm/src/script/__tests/Script.test.js.map +1 -0
- package/dist/esm/src/script/__tests/Spend.test.js +282 -0
- package/dist/esm/src/script/__tests/Spend.test.js.map +1 -0
- package/dist/esm/src/script/__tests/SpendComplex.test.js +51 -0
- package/dist/esm/src/script/__tests/SpendComplex.test.js.map +1 -0
- package/dist/esm/src/script/__tests/script.invalid.vectors.js +2370 -0
- package/dist/esm/src/script/__tests/script.invalid.vectors.js.map +1 -0
- package/dist/esm/src/script/__tests/script.valid.vectors.js +1181 -0
- package/dist/esm/src/script/__tests/script.valid.vectors.js.map +1 -0
- package/dist/esm/src/script/__tests/spend.valid.vectors.js +2298 -0
- package/dist/esm/src/script/__tests/spend.valid.vectors.js.map +1 -0
- package/dist/esm/src/script/index.js +31 -6
- package/dist/esm/src/script/index.js.map +1 -1
- package/dist/esm/src/script/templates/P2PKH.js +52 -39
- package/dist/esm/src/script/templates/P2PKH.js.map +1 -1
- package/dist/esm/src/script/templates/PushDrop.js +51 -46
- package/dist/esm/src/script/templates/PushDrop.js.map +1 -1
- package/dist/esm/src/script/templates/RPuzzle.js +55 -46
- package/dist/esm/src/script/templates/RPuzzle.js.map +1 -1
- package/dist/esm/src/script/templates/__tests/PushDrop.test.js +161 -0
- package/dist/esm/src/script/templates/__tests/PushDrop.test.js.map +1 -0
- package/dist/esm/src/script/templates/index.js +12 -3
- package/dist/esm/src/script/templates/index.js.map +1 -1
- package/dist/esm/src/totp/__tests/totp.test.js +67 -0
- package/dist/esm/src/totp/__tests/totp.test.js.map +1 -0
- package/dist/esm/src/totp/index.js +17 -1
- package/dist/esm/src/totp/index.js.map +1 -1
- package/dist/esm/src/totp/totp.js +15 -8
- package/dist/esm/src/totp/totp.js.map +1 -1
- package/dist/esm/src/transaction/Beef.js +160 -141
- package/dist/esm/src/transaction/Beef.js.map +1 -1
- package/dist/esm/src/transaction/BeefParty.js +30 -26
- package/dist/esm/src/transaction/BeefParty.js.map +1 -1
- package/dist/esm/src/transaction/BeefTx.js +32 -24
- package/dist/esm/src/transaction/BeefTx.js.map +1 -1
- package/dist/esm/src/transaction/Broadcaster.js +6 -2
- package/dist/esm/src/transaction/Broadcaster.js.map +1 -1
- package/dist/esm/src/transaction/ChainTracker.js +2 -1
- package/dist/esm/src/transaction/FeeModel.js +2 -1
- package/dist/esm/src/transaction/MerklePath.js +31 -23
- package/dist/esm/src/transaction/MerklePath.js.map +1 -1
- package/dist/esm/src/transaction/Transaction.js +96 -158
- package/dist/esm/src/transaction/Transaction.js.map +1 -1
- package/dist/esm/src/transaction/TransactionInput.js +2 -1
- package/dist/esm/src/transaction/TransactionOutput.js +2 -1
- package/dist/esm/src/transaction/__tests/Beef.test.js +393 -0
- package/dist/esm/src/transaction/__tests/Beef.test.js.map +1 -0
- package/dist/esm/src/transaction/__tests/MerklePath.test.js +209 -0
- package/dist/esm/src/transaction/__tests/MerklePath.test.js.map +1 -0
- package/dist/esm/src/transaction/__tests/Transaction.benchmarks.test.js +219 -0
- package/dist/esm/src/transaction/__tests/Transaction.benchmarks.test.js.map +1 -0
- package/dist/esm/src/transaction/__tests/Transaction.test.js +1072 -0
- package/dist/esm/src/transaction/__tests/Transaction.test.js.map +1 -0
- package/dist/esm/src/transaction/__tests/bigtx.vectors.js +7 -0
- package/dist/esm/src/transaction/__tests/bigtx.vectors.js.map +1 -0
- package/dist/esm/src/transaction/__tests/bump.invalid.vectors.js +11 -0
- package/dist/esm/src/transaction/__tests/bump.invalid.vectors.js.map +1 -0
- package/dist/esm/src/transaction/__tests/bump.valid.vectors.js +7 -0
- package/dist/esm/src/transaction/__tests/bump.valid.vectors.js.map +1 -0
- package/dist/esm/src/transaction/__tests/tx.invalid.vectors.js +230 -0
- package/dist/esm/src/transaction/__tests/tx.invalid.vectors.js.map +1 -0
- package/dist/esm/src/transaction/__tests/tx.valid.vectors.js +296 -0
- package/dist/esm/src/transaction/__tests/tx.valid.vectors.js.map +1 -0
- package/dist/esm/src/transaction/broadcasters/ARC.js +46 -36
- package/dist/esm/src/transaction/broadcasters/ARC.js.map +1 -1
- package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js +9 -3
- package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
- package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js +19 -16
- package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
- package/dist/esm/src/transaction/broadcasters/__tests/ARC.test.js +246 -0
- package/dist/esm/src/transaction/broadcasters/__tests/ARC.test.js.map +1 -0
- package/dist/esm/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.js +148 -0
- package/dist/esm/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.js.map +1 -0
- package/dist/esm/src/transaction/broadcasters/index.js +12 -3
- package/dist/esm/src/transaction/broadcasters/index.js.map +1 -1
- package/dist/esm/src/transaction/chaintrackers/DefaultChainTracker.js +9 -3
- package/dist/esm/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -1
- package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js +12 -9
- package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
- package/dist/esm/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.js +155 -0
- package/dist/esm/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.js.map +1 -0
- package/dist/esm/src/transaction/chaintrackers/index.js +10 -2
- package/dist/esm/src/transaction/chaintrackers/index.js.map +1 -1
- package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js +7 -4
- package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
- package/dist/esm/src/transaction/fee-models/index.js +8 -1
- package/dist/esm/src/transaction/fee-models/index.js.map +1 -1
- package/dist/esm/src/transaction/http/DefaultHttpClient.js +15 -12
- package/dist/esm/src/transaction/http/DefaultHttpClient.js.map +1 -1
- package/dist/esm/src/transaction/http/FetchHttpClient.js +9 -3
- package/dist/esm/src/transaction/http/FetchHttpClient.js.map +1 -1
- package/dist/esm/src/transaction/http/HttpClient.js +2 -1
- package/dist/esm/src/transaction/http/NodejsHttpClient.js +15 -9
- package/dist/esm/src/transaction/http/NodejsHttpClient.js.map +1 -1
- package/dist/esm/src/transaction/http/index.js +9 -3
- package/dist/esm/src/transaction/http/index.js.map +1 -1
- package/dist/esm/src/transaction/index.js +32 -6
- package/dist/esm/src/transaction/index.js.map +1 -1
- package/dist/esm/src/wallet/CachedKeyDeriver.js +69 -64
- package/dist/esm/src/wallet/CachedKeyDeriver.js.map +1 -1
- package/dist/esm/src/wallet/KeyDeriver.js +72 -60
- package/dist/esm/src/wallet/KeyDeriver.js.map +1 -1
- package/dist/esm/src/wallet/ProtoWallet.js +33 -16
- package/dist/esm/src/wallet/ProtoWallet.js.map +1 -1
- package/dist/esm/src/wallet/Wallet.interfaces.js +5 -2
- package/dist/esm/src/wallet/Wallet.interfaces.js.map +1 -1
- package/dist/esm/src/wallet/WalletClient.js +22 -15
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/src/wallet/WalletError.js +6 -2
- package/dist/esm/src/wallet/WalletError.js.map +1 -1
- package/dist/esm/src/wallet/__tests/CachedKeyDeriver.test.js +269 -0
- package/dist/esm/src/wallet/__tests/CachedKeyDeriver.test.js.map +1 -0
- package/dist/esm/src/wallet/__tests/KeyDeriver.test.js +113 -0
- package/dist/esm/src/wallet/__tests/KeyDeriver.test.js.map +1 -0
- package/dist/esm/src/wallet/__tests/ProtoWallet.test.js +475 -0
- package/dist/esm/src/wallet/__tests/ProtoWallet.test.js.map +1 -0
- package/dist/esm/src/wallet/index.js +32 -8
- package/dist/esm/src/wallet/index.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +7 -4
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletWire.js +17 -11
- package/dist/esm/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWire.js +2 -1
- package/dist/esm/src/wallet/substrates/WalletWireCalls.js +3 -1
- package/dist/esm/src/wallet/substrates/WalletWireCalls.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1300 -1317
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +327 -273
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/esm/src/wallet/substrates/XDM.js +12 -6
- package/dist/esm/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/esm/src/wallet/substrates/__tests/WalletWire.integration.test.js +1962 -0
- package/dist/esm/src/wallet/substrates/__tests/WalletWire.integration.test.js.map +1 -0
- package/dist/esm/src/wallet/substrates/__tests/XDM.test.js +579 -0
- package/dist/esm/src/wallet/substrates/__tests/XDM.test.js.map +1 -0
- package/dist/esm/src/wallet/substrates/index.js +32 -7
- package/dist/esm/src/wallet/substrates/index.js.map +1 -1
- package/dist/esm/src/wallet/substrates/window.CWI.js +8 -5
- package/dist/esm/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/mod.d.ts +15 -15
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/types/src/auth/Peer.d.ts +14 -14
- package/dist/types/src/auth/Peer.d.ts.map +1 -1
- package/dist/types/src/auth/SessionManager.d.ts +5 -5
- package/dist/types/src/auth/SessionManager.d.ts.map +1 -1
- package/dist/types/src/auth/__tests/Peer.test.d.ts +2 -0
- package/dist/types/src/auth/__tests/Peer.test.d.ts.map +1 -0
- package/dist/types/src/auth/__tests/SessionManager.test.d.ts +2 -0
- package/dist/types/src/auth/__tests/SessionManager.test.d.ts.map +1 -0
- package/dist/types/src/auth/certificates/Certificate.d.ts +2 -2
- package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts +2 -2
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts +2 -2
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/__tests/Certificate.test.d.ts +2 -0
- package/dist/types/src/auth/certificates/__tests/Certificate.test.d.ts.map +1 -0
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts +2 -2
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/__tests/MasterCertificate.test.d.ts +2 -0
- package/dist/types/src/auth/certificates/__tests/MasterCertificate.test.d.ts.map +1 -0
- package/dist/types/src/auth/certificates/__tests/VerifiableCertificate.test.d.ts +2 -0
- package/dist/types/src/auth/certificates/__tests/VerifiableCertificate.test.d.ts.map +1 -0
- package/dist/types/src/auth/certificates/index.d.ts +4 -4
- package/dist/types/src/auth/certificates/index.d.ts.map +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts +9 -9
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/src/auth/clients/index.d.ts +1 -1
- package/dist/types/src/auth/clients/index.d.ts.map +1 -1
- package/dist/types/src/auth/index.d.ts +7 -7
- package/dist/types/src/auth/index.d.ts.map +1 -1
- package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts +1 -1
- package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts.map +1 -1
- package/dist/types/src/auth/transports/index.d.ts +1 -1
- package/dist/types/src/auth/transports/index.d.ts.map +1 -1
- package/dist/types/src/auth/types.d.ts +1 -1
- package/dist/types/src/auth/types.d.ts.map +1 -1
- package/dist/types/src/auth/utils/__tests/cryptononce.test.d.ts +2 -0
- package/dist/types/src/auth/utils/__tests/cryptononce.test.d.ts.map +1 -0
- package/dist/types/src/auth/utils/__tests/getVerifiableCertificates.test.d.ts +2 -0
- package/dist/types/src/auth/utils/__tests/getVerifiableCertificates.test.d.ts.map +1 -0
- package/dist/types/src/auth/utils/__tests/validateCertificates.test.d.ts +2 -0
- package/dist/types/src/auth/utils/__tests/validateCertificates.test.d.ts.map +1 -0
- package/dist/types/src/auth/utils/createNonce.d.ts +1 -1
- package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -1
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts +3 -3
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts.map +1 -1
- package/dist/types/src/auth/utils/index.d.ts +4 -4
- package/dist/types/src/auth/utils/index.d.ts.map +1 -1
- package/dist/types/src/auth/utils/validateCertificates.d.ts +2 -2
- package/dist/types/src/auth/utils/validateCertificates.d.ts.map +1 -1
- package/dist/types/src/auth/utils/verifyNonce.d.ts +1 -1
- package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -1
- package/dist/types/src/compat/BSM.d.ts +3 -3
- package/dist/types/src/compat/BSM.d.ts.map +1 -1
- package/dist/types/src/compat/ECIES.d.ts +38 -38
- package/dist/types/src/compat/ECIES.d.ts.map +1 -1
- package/dist/types/src/compat/HD.d.ts +53 -53
- package/dist/types/src/compat/HD.d.ts.map +1 -1
- package/dist/types/src/compat/Mnemonic.d.ts +79 -79
- package/dist/types/src/compat/Mnemonic.d.ts.map +1 -1
- package/dist/types/src/compat/Utxo.d.ts +3 -3
- package/dist/types/src/compat/Utxo.d.ts.map +1 -1
- package/dist/types/src/compat/__tests/BSM.test.d.ts +2 -0
- package/dist/types/src/compat/__tests/BSM.test.d.ts.map +1 -0
- package/dist/types/src/compat/__tests/ECIES.test.d.ts +2 -0
- package/dist/types/src/compat/__tests/ECIES.test.d.ts.map +1 -0
- package/dist/types/src/compat/__tests/HD.test.d.ts +2 -0
- package/dist/types/src/compat/__tests/HD.test.d.ts.map +1 -0
- package/dist/types/src/compat/__tests/Mnemonic.test.d.ts +2 -0
- package/dist/types/src/compat/__tests/Mnemonic.test.d.ts.map +1 -0
- package/dist/types/src/compat/__tests/Mnemonic.vectors.d.ts +11 -0
- package/dist/types/src/compat/__tests/Mnemonic.vectors.d.ts.map +1 -0
- package/dist/types/src/compat/index.d.ts +5 -5
- package/dist/types/src/compat/index.d.ts.map +1 -1
- package/dist/types/src/messages/EncryptedMessage.d.ts +2 -2
- package/dist/types/src/messages/EncryptedMessage.d.ts.map +1 -1
- package/dist/types/src/messages/SignedMessage.d.ts +2 -2
- package/dist/types/src/messages/SignedMessage.d.ts.map +1 -1
- package/dist/types/src/messages/__tests/EncryptedMessage.test.d.ts +2 -0
- package/dist/types/src/messages/__tests/EncryptedMessage.test.d.ts.map +1 -0
- package/dist/types/src/messages/__tests/SignedMessage.test.d.ts +2 -0
- package/dist/types/src/messages/__tests/SignedMessage.test.d.ts.map +1 -0
- package/dist/types/src/messages/index.d.ts +2 -2
- package/dist/types/src/messages/index.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts +9 -9
- package/dist/types/src/overlay-tools/LookupResolver.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts +21 -21
- package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts +16 -16
- package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/__tests/LookupResolver.test.d.ts +2 -0
- package/dist/types/src/overlay-tools/__tests/LookupResolver.test.d.ts.map +1 -0
- package/dist/types/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.d.ts +2 -0
- package/dist/types/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.d.ts.map +1 -0
- package/dist/types/src/overlay-tools/__tests/SHIPBroadcaster.test.d.ts +2 -0
- package/dist/types/src/overlay-tools/__tests/SHIPBroadcaster.test.d.ts.map +1 -0
- package/dist/types/src/overlay-tools/index.d.ts +5 -5
- package/dist/types/src/overlay-tools/index.d.ts.map +1 -1
- package/dist/types/src/primitives/BasePoint.d.ts +1 -1
- package/dist/types/src/primitives/BasePoint.d.ts.map +1 -1
- package/dist/types/src/primitives/BigNumber.d.ts +1 -1
- package/dist/types/src/primitives/BigNumber.d.ts.map +1 -1
- package/dist/types/src/primitives/Curve.d.ts +3 -3
- package/dist/types/src/primitives/Curve.d.ts.map +1 -1
- package/dist/types/src/primitives/DRBG.d.ts +1 -1
- package/dist/types/src/primitives/DRBG.d.ts.map +1 -1
- package/dist/types/src/primitives/ECDSA.d.ts +3 -3
- package/dist/types/src/primitives/ECDSA.d.ts.map +1 -1
- package/dist/types/src/primitives/Hash.d.ts.map +1 -1
- package/dist/types/src/primitives/JacobianPoint.d.ts +3 -3
- package/dist/types/src/primitives/JacobianPoint.d.ts.map +1 -1
- package/dist/types/src/primitives/K256.d.ts +2 -2
- package/dist/types/src/primitives/K256.d.ts.map +1 -1
- package/dist/types/src/primitives/Mersenne.d.ts +1 -1
- package/dist/types/src/primitives/Mersenne.d.ts.map +1 -1
- package/dist/types/src/primitives/MontgomoryMethod.d.ts +2 -2
- package/dist/types/src/primitives/MontgomoryMethod.d.ts.map +1 -1
- package/dist/types/src/primitives/Point.d.ts +17 -13
- package/dist/types/src/primitives/Point.d.ts.map +1 -1
- package/dist/types/src/primitives/Polynomial.d.ts +2 -2
- package/dist/types/src/primitives/Polynomial.d.ts.map +1 -1
- package/dist/types/src/primitives/PrivateKey.d.ts +5 -5
- package/dist/types/src/primitives/PrivateKey.d.ts.map +1 -1
- package/dist/types/src/primitives/PublicKey.d.ts +4 -4
- package/dist/types/src/primitives/PublicKey.d.ts.map +1 -1
- package/dist/types/src/primitives/Random.d.ts.map +1 -1
- package/dist/types/src/primitives/ReductionContext.d.ts +2 -2
- package/dist/types/src/primitives/ReductionContext.d.ts.map +1 -1
- package/dist/types/src/primitives/Schnorr.d.ts +17 -17
- package/dist/types/src/primitives/Schnorr.d.ts.map +1 -1
- package/dist/types/src/primitives/Signature.d.ts +2 -2
- package/dist/types/src/primitives/Signature.d.ts.map +1 -1
- package/dist/types/src/primitives/SymmetricKey.d.ts +14 -14
- package/dist/types/src/primitives/SymmetricKey.d.ts.map +1 -1
- package/dist/types/src/primitives/TransactionSignature.d.ts +9 -9
- package/dist/types/src/primitives/TransactionSignature.d.ts.map +1 -1
- package/dist/types/src/primitives/__tests/AESGCM.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/AESGCM.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/BRC42.private.vectors.d.ts +8 -0
- package/dist/types/src/primitives/__tests/BRC42.private.vectors.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/BRC42.public.vectors.d.ts +8 -0
- package/dist/types/src/primitives/__tests/BRC42.public.vectors.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/BigNumber.arithmatic.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/BigNumber.arithmatic.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/BigNumber.binary.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/BigNumber.binary.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/BigNumber.constructor.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/BigNumber.constructor.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/BigNumber.dhGroup.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/BigNumber.dhGroup.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/BigNumber.fixtures.d.ts +15 -0
- package/dist/types/src/primitives/__tests/BigNumber.fixtures.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/BigNumber.serializers.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/BigNumber.serializers.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/BigNumber.utils.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/BigNumber.utils.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/Curve.unit.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/Curve.unit.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/DRBG.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/DRBG.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/DRBG.vectors.d.ts +10 -0
- package/dist/types/src/primitives/__tests/DRBG.vectors.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/ECDH.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/ECDH.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/ECDSA.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/ECDSA.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/HMAC.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/HMAC.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/Hash.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/Hash.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/PBKDF2.vectors.d.ts +68 -0
- package/dist/types/src/primitives/__tests/PBKDF2.vectors.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/PrivateKey.split.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/PrivateKey.split.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/PrivateKey.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/PrivateKey.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/PublicKey.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/PublicKey.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/Random.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/Random.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/Reader.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/Reader.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/ReductionContext.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/ReductionContext.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/Schnorr.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/Schnorr.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/SymmetricKey.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/SymmetricKey.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/SymmetricKey.vectors.d.ts +20 -0
- package/dist/types/src/primitives/__tests/SymmetricKey.vectors.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/Writer.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/Writer.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/bug-31.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/bug-31.test.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/sighash.vectors.d.ts +3 -0
- package/dist/types/src/primitives/__tests/sighash.vectors.d.ts.map +1 -0
- package/dist/types/src/primitives/__tests/utils.test.d.ts +2 -0
- package/dist/types/src/primitives/__tests/utils.test.d.ts.map +1 -0
- package/dist/types/src/primitives/index.d.ts +14 -14
- package/dist/types/src/primitives/index.d.ts.map +1 -1
- package/dist/types/src/primitives/utils.d.ts +1 -1
- package/dist/types/src/primitives/utils.d.ts.map +1 -1
- package/dist/types/src/script/LockingScript.d.ts +1 -1
- package/dist/types/src/script/LockingScript.d.ts.map +1 -1
- package/dist/types/src/script/Script.d.ts +5 -5
- package/dist/types/src/script/Script.d.ts.map +1 -1
- package/dist/types/src/script/ScriptTemplate.d.ts +3 -3
- package/dist/types/src/script/ScriptTemplate.d.ts.map +1 -1
- package/dist/types/src/script/Spend.d.ts +4 -4
- package/dist/types/src/script/Spend.d.ts.map +1 -1
- package/dist/types/src/script/UnlockingScript.d.ts +1 -1
- package/dist/types/src/script/UnlockingScript.d.ts.map +1 -1
- package/dist/types/src/script/__tests/Script.test.d.ts +2 -0
- package/dist/types/src/script/__tests/Script.test.d.ts.map +1 -0
- package/dist/types/src/script/__tests/Spend.test.d.ts +2 -0
- package/dist/types/src/script/__tests/Spend.test.d.ts.map +1 -0
- package/dist/types/src/script/__tests/SpendComplex.test.d.ts +2 -0
- package/dist/types/src/script/__tests/SpendComplex.test.d.ts.map +1 -0
- package/dist/types/src/script/__tests/script.invalid.vectors.d.ts +3 -0
- package/dist/types/src/script/__tests/script.invalid.vectors.d.ts.map +1 -0
- package/dist/types/src/script/__tests/script.valid.vectors.d.ts +3 -0
- package/dist/types/src/script/__tests/script.valid.vectors.d.ts.map +1 -0
- package/dist/types/src/script/__tests/spend.valid.vectors.d.ts +3 -0
- package/dist/types/src/script/__tests/spend.valid.vectors.d.ts.map +1 -0
- package/dist/types/src/script/index.d.ts +7 -7
- package/dist/types/src/script/index.d.ts.map +1 -1
- package/dist/types/src/script/templates/P2PKH.d.ts +7 -7
- package/dist/types/src/script/templates/P2PKH.d.ts.map +1 -1
- package/dist/types/src/script/templates/PushDrop.d.ts +7 -7
- package/dist/types/src/script/templates/PushDrop.d.ts.map +1 -1
- package/dist/types/src/script/templates/RPuzzle.d.ts +9 -9
- package/dist/types/src/script/templates/RPuzzle.d.ts.map +1 -1
- package/dist/types/src/script/templates/__tests/PushDrop.test.d.ts +2 -0
- package/dist/types/src/script/templates/__tests/PushDrop.test.d.ts.map +1 -0
- package/dist/types/src/script/templates/index.d.ts +3 -3
- package/dist/types/src/script/templates/index.d.ts.map +1 -1
- package/dist/types/src/totp/__tests/totp.test.d.ts +2 -0
- package/dist/types/src/totp/__tests/totp.test.d.ts.map +1 -0
- package/dist/types/src/totp/index.d.ts +1 -1
- package/dist/types/src/totp/index.d.ts.map +1 -1
- package/dist/types/src/transaction/Beef.d.ts +96 -96
- package/dist/types/src/transaction/Beef.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefParty.d.ts +23 -23
- package/dist/types/src/transaction/BeefParty.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefTx.d.ts +5 -5
- package/dist/types/src/transaction/BeefTx.d.ts.map +1 -1
- package/dist/types/src/transaction/Broadcaster.d.ts +1 -1
- package/dist/types/src/transaction/Broadcaster.d.ts.map +1 -1
- package/dist/types/src/transaction/ChainTracker.d.ts +2 -2
- package/dist/types/src/transaction/FeeModel.d.ts +1 -1
- package/dist/types/src/transaction/FeeModel.d.ts.map +1 -1
- package/dist/types/src/transaction/MerklePath.d.ts +2 -2
- package/dist/types/src/transaction/MerklePath.d.ts.map +1 -1
- package/dist/types/src/transaction/Transaction.d.ts +11 -19
- package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
- package/dist/types/src/transaction/TransactionInput.d.ts +2 -2
- package/dist/types/src/transaction/TransactionInput.d.ts.map +1 -1
- package/dist/types/src/transaction/TransactionOutput.d.ts +1 -1
- package/dist/types/src/transaction/TransactionOutput.d.ts.map +1 -1
- package/dist/types/src/transaction/__tests/Beef.test.d.ts +2 -0
- package/dist/types/src/transaction/__tests/Beef.test.d.ts.map +1 -0
- package/dist/types/src/transaction/__tests/MerklePath.test.d.ts +2 -0
- package/dist/types/src/transaction/__tests/MerklePath.test.d.ts.map +1 -0
- package/dist/types/src/transaction/__tests/Transaction.benchmarks.test.d.ts +2 -0
- package/dist/types/src/transaction/__tests/Transaction.benchmarks.test.d.ts.map +1 -0
- package/dist/types/src/transaction/__tests/Transaction.test.d.ts +2 -0
- package/dist/types/src/transaction/__tests/Transaction.test.d.ts.map +1 -0
- package/dist/types/src/transaction/__tests/bigtx.vectors.d.ts +6 -0
- package/dist/types/src/transaction/__tests/bigtx.vectors.d.ts.map +1 -0
- package/dist/types/src/transaction/__tests/bump.invalid.vectors.d.ts +6 -0
- package/dist/types/src/transaction/__tests/bump.invalid.vectors.d.ts.map +1 -0
- package/dist/types/src/transaction/__tests/bump.valid.vectors.d.ts +5 -0
- package/dist/types/src/transaction/__tests/bump.valid.vectors.d.ts.map +1 -0
- package/dist/types/src/transaction/__tests/tx.invalid.vectors.d.ts +3 -0
- package/dist/types/src/transaction/__tests/tx.invalid.vectors.d.ts.map +1 -0
- package/dist/types/src/transaction/__tests/tx.valid.vectors.d.ts +3 -0
- package/dist/types/src/transaction/__tests/tx.valid.vectors.d.ts.map +1 -0
- package/dist/types/src/transaction/broadcasters/ARC.d.ts +3 -3
- package/dist/types/src/transaction/broadcasters/ARC.d.ts.map +1 -1
- package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts +2 -2
- package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts.map +1 -1
- package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts +4 -4
- package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts.map +1 -1
- package/dist/types/src/transaction/broadcasters/__tests/ARC.test.d.ts +2 -0
- package/dist/types/src/transaction/broadcasters/__tests/ARC.test.d.ts.map +1 -0
- package/dist/types/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.d.ts +2 -0
- package/dist/types/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.d.ts.map +1 -0
- package/dist/types/src/transaction/broadcasters/index.d.ts +4 -4
- package/dist/types/src/transaction/broadcasters/index.d.ts.map +1 -1
- package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts +1 -1
- package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts.map +1 -1
- package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts +3 -3
- package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts.map +1 -1
- package/dist/types/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.d.ts +2 -0
- package/dist/types/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.d.ts.map +1 -0
- package/dist/types/src/transaction/chaintrackers/index.d.ts +3 -3
- package/dist/types/src/transaction/chaintrackers/index.d.ts.map +1 -1
- package/dist/types/src/transaction/fee-models/SatoshisPerKilobyte.d.ts +2 -2
- package/dist/types/src/transaction/fee-models/SatoshisPerKilobyte.d.ts.map +1 -1
- package/dist/types/src/transaction/fee-models/index.d.ts +1 -1
- package/dist/types/src/transaction/fee-models/index.d.ts.map +1 -1
- package/dist/types/src/transaction/http/DefaultHttpClient.d.ts +2 -2
- package/dist/types/src/transaction/http/DefaultHttpClient.d.ts.map +1 -1
- package/dist/types/src/transaction/http/FetchHttpClient.d.ts +6 -6
- package/dist/types/src/transaction/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/types/src/transaction/http/HttpClient.d.ts +4 -4
- package/dist/types/src/transaction/http/HttpClient.d.ts.map +1 -1
- package/dist/types/src/transaction/http/NodejsHttpClient.d.ts +4 -4
- package/dist/types/src/transaction/http/NodejsHttpClient.d.ts.map +1 -1
- package/dist/types/src/transaction/http/index.d.ts +6 -6
- package/dist/types/src/transaction/http/index.d.ts.map +1 -1
- package/dist/types/src/transaction/index.d.ts +10 -10
- package/dist/types/src/transaction/index.d.ts.map +1 -1
- package/dist/types/src/wallet/CachedKeyDeriver.d.ts +61 -61
- package/dist/types/src/wallet/CachedKeyDeriver.d.ts.map +1 -1
- package/dist/types/src/wallet/KeyDeriver.d.ts +80 -80
- package/dist/types/src/wallet/KeyDeriver.d.ts.map +1 -1
- package/dist/types/src/wallet/ProtoWallet.d.ts +3 -3
- package/dist/types/src/wallet/ProtoWallet.d.ts.map +1 -1
- package/dist/types/src/wallet/Wallet.interfaces.d.ts +144 -144
- package/dist/types/src/wallet/Wallet.interfaces.d.ts.map +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
- package/dist/types/src/wallet/__tests/CachedKeyDeriver.test.d.ts +2 -0
- package/dist/types/src/wallet/__tests/CachedKeyDeriver.test.d.ts.map +1 -0
- package/dist/types/src/wallet/__tests/KeyDeriver.test.d.ts +2 -0
- package/dist/types/src/wallet/__tests/KeyDeriver.test.d.ts.map +1 -0
- package/dist/types/src/wallet/__tests/ProtoWallet.test.d.ts +2 -0
- package/dist/types/src/wallet/__tests/ProtoWallet.test.d.ts.map +1 -0
- package/dist/types/src/wallet/index.d.ts +8 -8
- package/dist/types/src/wallet/index.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletWire.d.ts +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletWire.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWire.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWireCalls.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWireProcessor.d.ts +2 -2
- package/dist/types/src/wallet/substrates/WalletWireProcessor.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts +10 -10
- package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/XDM.d.ts +2 -2
- package/dist/types/src/wallet/substrates/XDM.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/__tests/WalletWire.integration.test.d.ts +2 -0
- package/dist/types/src/wallet/substrates/__tests/WalletWire.integration.test.d.ts.map +1 -0
- package/dist/types/src/wallet/substrates/__tests/XDM.test.d.ts +5 -0
- package/dist/types/src/wallet/substrates/__tests/XDM.test.d.ts.map +1 -0
- package/dist/types/src/wallet/substrates/index.d.ts +7 -7
- package/dist/types/src/wallet/substrates/index.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/window.CWI.d.ts +19 -19
- package/dist/types/src/wallet/substrates/window.CWI.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/auth.md +55 -51
- package/docs/compat.md +24 -24
- package/docs/messages.md +7 -5
- package/docs/overlay-tools.md +21 -21
- package/docs/primitives.md +239 -242
- package/docs/script.md +31 -31
- package/docs/totp.md +5 -5
- package/docs/transaction.md +76 -78
- package/docs/wallet-substrates.md +6 -6
- package/docs/wallet.md +129 -129
- package/mod.ts +15 -15
- package/package.json +10 -2
- package/src/auth/Peer.ts +217 -72
- package/src/auth/SessionManager.ts +8 -6
- package/src/auth/__tests/Peer.test.ts +314 -159
- package/src/auth/certificates/Certificate.ts +16 -6
- package/src/auth/certificates/MasterCertificate.ts +96 -43
- package/src/auth/certificates/VerifiableCertificate.ts +29 -9
- package/src/auth/certificates/__tests/Certificate.test.ts +160 -146
- package/src/auth/certificates/__tests/CompletedProtoWallet.ts +148 -59
- package/src/auth/certificates/__tests/MasterCertificate.test.ts +65 -41
- package/src/auth/certificates/__tests/VerifiableCertificate.test.ts +47 -31
- package/src/auth/certificates/index.ts +4 -4
- package/src/auth/clients/AuthFetch.ts +316 -231
- package/src/auth/clients/index.ts +1 -1
- package/src/auth/index.ts +7 -7
- package/src/auth/transports/SimplifiedFetchTransport.ts +166 -124
- package/src/auth/transports/index.ts +1 -1
- package/src/auth/types.ts +1 -1
- package/src/auth/utils/__tests/cryptononce.test.ts +52 -25
- package/src/auth/utils/__tests/getVerifiableCertificates.test.ts +64 -38
- package/src/auth/utils/__tests/validateCertificates.test.ts +101 -89
- package/src/auth/utils/createNonce.ts +11 -3
- package/src/auth/utils/getVerifiableCertificates.ts +11 -6
- package/src/auth/utils/index.ts +4 -4
- package/src/auth/utils/validateCertificates.ts +53 -39
- package/src/auth/utils/verifyNonce.ts +6 -2
- package/src/compat/BSM.ts +17 -9
- package/src/compat/ECIES.ts +239 -123
- package/src/compat/HD.ts +82 -63
- package/src/compat/Mnemonic.ts +98 -87
- package/src/compat/Utxo.ts +12 -9
- package/src/compat/__tests/BSM.test.ts +43 -16
- package/src/compat/__tests/ECIES.test.ts +117 -52
- package/src/compat/__tests/HD.test.ts +49 -38
- package/src/compat/__tests/Mnemonic.test.ts +145 -145
- package/src/compat/index.ts +5 -5
- package/src/messages/EncryptedMessage.ts +11 -7
- package/src/messages/SignedMessage.ts +19 -14
- package/src/messages/__tests/EncryptedMessage.test.ts +55 -56
- package/src/messages/__tests/SignedMessage.test.ts +58 -52
- package/src/messages/index.ts +2 -2
- package/src/overlay-tools/LookupResolver.ts +65 -33
- package/src/overlay-tools/OverlayAdminTokenTemplate.ts +52 -27
- package/src/overlay-tools/SHIPBroadcaster.ts +134 -59
- package/src/overlay-tools/__tests/LookupResolver.test.ts +723 -323
- package/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.ts +50 -22
- package/src/overlay-tools/__tests/SHIPBroadcaster.test.ts +607 -290
- package/src/overlay-tools/index.ts +5 -5
- package/src/primitives/BasePoint.ts +1 -1
- package/src/primitives/BigNumber.ts +94 -87
- package/src/primitives/Curve.ts +49 -30
- package/src/primitives/DRBG.ts +10 -12
- package/src/primitives/ECDSA.ts +59 -33
- package/src/primitives/Hash.ts +298 -179
- package/src/primitives/JacobianPoint.ts +55 -21
- package/src/primitives/K256.ts +2 -2
- package/src/primitives/Mersenne.ts +1 -1
- package/src/primitives/MontgomoryMethod.ts +2 -2
- package/src/primitives/Point.ts +193 -113
- package/src/primitives/Polynomial.ts +12 -7
- package/src/primitives/PrivateKey.ts +44 -20
- package/src/primitives/PublicKey.ts +21 -11
- package/src/primitives/Random.ts +7 -5
- package/src/primitives/ReductionContext.ts +4 -4
- package/src/primitives/Schnorr.ts +45 -23
- package/src/primitives/Signature.ts +27 -19
- package/src/primitives/SymmetricKey.ts +17 -17
- package/src/primitives/TransactionSignature.ts +29 -18
- package/src/primitives/__tests/AESGCM.test.ts +635 -329
- package/src/primitives/__tests/BigNumber.arithmatic.test.ts +721 -502
- package/src/primitives/__tests/BigNumber.binary.test.ts +271 -190
- package/src/primitives/__tests/BigNumber.constructor.test.ts +60 -24
- package/src/primitives/__tests/BigNumber.dhGroup.test.ts +19 -15
- package/src/primitives/__tests/BigNumber.serializers.test.ts +183 -157
- package/src/primitives/__tests/BigNumber.utils.test.ts +394 -304
- package/src/primitives/__tests/Curve.unit.test.ts +158 -143
- package/src/primitives/__tests/DRBG.test.ts +13 -13
- package/src/primitives/__tests/ECDH.test.ts +15 -8
- package/src/primitives/__tests/ECDSA.test.ts +63 -57
- package/src/primitives/__tests/HMAC.test.ts +55 -49
- package/src/primitives/__tests/Hash.test.ts +96 -85
- package/src/primitives/__tests/PrivateKey.split.test.ts +29 -9
- package/src/primitives/__tests/PrivateKey.test.ts +53 -50
- package/src/primitives/__tests/PublicKey.test.ts +15 -6
- package/src/primitives/__tests/Random.test.ts +10 -10
- package/src/primitives/__tests/Reader.test.ts +240 -219
- package/src/primitives/__tests/ReductionContext.test.ts +271 -234
- package/src/primitives/__tests/Schnorr.test.ts +252 -242
- package/src/primitives/__tests/SymmetricKey.test.ts +53 -50
- package/src/primitives/__tests/Writer.test.ts +23 -13
- package/src/primitives/__tests/bug-31.test.ts +25 -23
- package/src/primitives/__tests/utils.test.ts +70 -19
- package/src/primitives/index.ts +14 -14
- package/src/primitives/utils.ts +88 -63
- package/src/script/LockingScript.ts +1 -1
- package/src/script/Script.ts +14 -10
- package/src/script/ScriptTemplate.ts +5 -7
- package/src/script/Spend.ts +314 -118
- package/src/script/UnlockingScript.ts +1 -1
- package/src/script/__tests/Script.test.ts +68 -54
- package/src/script/__tests/Spend.test.ts +188 -68
- package/src/script/__tests/SpendComplex.test.ts +36 -26
- package/src/script/__tests/script.valid.vectors.ts +1064 -3100
- package/src/script/index.ts +7 -7
- package/src/script/templates/P2PKH.ts +63 -52
- package/src/script/templates/PushDrop.ts +117 -89
- package/src/script/templates/RPuzzle.ts +72 -54
- package/src/script/templates/__tests/PushDrop.test.ts +146 -40
- package/src/script/templates/index.ts +3 -3
- package/src/totp/__tests/totp.test.ts +39 -39
- package/src/totp/index.ts +1 -1
- package/src/totp/totp.ts +2 -2
- package/src/transaction/Beef.ts +211 -141
- package/src/transaction/BeefParty.ts +35 -27
- package/src/transaction/BeefTx.ts +13 -9
- package/src/transaction/Broadcaster.ts +11 -7
- package/src/transaction/ChainTracker.ts +2 -2
- package/src/transaction/FeeModel.ts +2 -2
- package/src/transaction/MerklePath.ts +81 -37
- package/src/transaction/Transaction.ts +185 -208
- package/src/transaction/TransactionInput.ts +2 -2
- package/src/transaction/TransactionOutput.ts +2 -2
- package/src/transaction/__tests/Beef.test.ts +359 -297
- package/src/transaction/__tests/MerklePath.test.ts +163 -131
- package/src/transaction/__tests/Transaction.benchmarks.test.ts +235 -202
- package/src/transaction/__tests/Transaction.test.ts +746 -459
- package/src/transaction/broadcasters/ARC.ts +120 -94
- package/src/transaction/broadcasters/DefaultBroadcaster.ts +11 -5
- package/src/transaction/broadcasters/WhatsOnChainBroadcaster.ts +46 -33
- package/src/transaction/broadcasters/__tests/ARC.test.ts +77 -45
- package/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.ts +25 -17
- package/src/transaction/broadcasters/index.ts +4 -4
- package/src/transaction/chaintrackers/DefaultChainTracker.ts +4 -4
- package/src/transaction/chaintrackers/WhatsOnChain.ts +53 -38
- package/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.ts +138 -102
- package/src/transaction/chaintrackers/index.ts +3 -3
- package/src/transaction/fee-models/SatoshisPerKilobyte.ts +37 -32
- package/src/transaction/fee-models/index.ts +1 -1
- package/src/transaction/http/DefaultHttpClient.ts +17 -17
- package/src/transaction/http/FetchHttpClient.ts +18 -9
- package/src/transaction/http/HttpClient.ts +30 -25
- package/src/transaction/http/NodejsHttpClient.ts +42 -28
- package/src/transaction/http/index.ts +10 -6
- package/src/transaction/index.ts +14 -10
- package/src/wallet/CachedKeyDeriver.ts +118 -72
- package/src/wallet/KeyDeriver.ts +186 -105
- package/src/wallet/ProtoWallet.ts +53 -17
- package/src/wallet/Wallet.interfaces.ts +158 -149
- package/src/wallet/WalletClient.ts +316 -58
- package/src/wallet/__tests/CachedKeyDeriver.test.ts +83 -27
- package/src/wallet/__tests/KeyDeriver.test.ts +219 -116
- package/src/wallet/__tests/ProtoWallet.test.ts +420 -339
- package/src/wallet/index.ts +8 -8
- package/src/wallet/substrates/HTTPWalletJSON.ts +201 -32
- package/src/wallet/substrates/HTTPWalletWire.ts +30 -26
- package/src/wallet/substrates/WalletWire.ts +1 -1
- package/src/wallet/substrates/WalletWireCalls.ts +3 -3
- package/src/wallet/substrates/WalletWireProcessor.ts +1651 -1515
- package/src/wallet/substrates/WalletWireTransceiver.ts +1424 -854
- package/src/wallet/substrates/XDM.ts +427 -37
- package/src/wallet/substrates/__tests/WalletWire.integration.test.ts +484 -223
- package/src/wallet/substrates/__tests/XDM.test.ts +191 -195
- package/src/wallet/substrates/index.ts +7 -7
- package/src/wallet/substrates/window.CWI.ts +524 -65
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const index_1 = require("../../primitives/index");
|
|
7
|
+
const WalletWireCalls_1 = __importDefault(require("./WalletWireCalls"));
|
|
8
|
+
const Certificate_1 = __importDefault(require("../../auth/certificates/Certificate"));
|
|
9
9
|
/**
|
|
10
10
|
* Processes incoming wallet calls received over a wallet wire, with a given wallet.
|
|
11
11
|
*/
|
|
@@ -15,24 +15,24 @@ class WalletWireProcessor {
|
|
|
15
15
|
}
|
|
16
16
|
decodeOutpoint(reader) {
|
|
17
17
|
const txidBytes = reader.read(32);
|
|
18
|
-
const txid =
|
|
18
|
+
const txid = index_1.Utils.toHex(txidBytes);
|
|
19
19
|
const index = reader.readVarIntNum();
|
|
20
20
|
return `${txid}.${index}`;
|
|
21
21
|
}
|
|
22
22
|
encodeOutpoint(outpoint) {
|
|
23
|
-
const writer = new
|
|
24
|
-
const [txid, index] = outpoint.split(
|
|
25
|
-
writer.write(
|
|
23
|
+
const writer = new index_1.Utils.Writer();
|
|
24
|
+
const [txid, index] = outpoint.split(".");
|
|
25
|
+
writer.write(index_1.Utils.toArray(txid, "hex"));
|
|
26
26
|
writer.writeVarIntNum(Number(index));
|
|
27
27
|
return writer.toArray();
|
|
28
28
|
}
|
|
29
29
|
async transmitToWallet(message) {
|
|
30
|
-
const messageReader = new
|
|
30
|
+
const messageReader = new index_1.Utils.Reader(message);
|
|
31
31
|
try {
|
|
32
32
|
// Read call code
|
|
33
33
|
const callCode = messageReader.readUInt8();
|
|
34
34
|
// Map call code to call name
|
|
35
|
-
const callName =
|
|
35
|
+
const callName = WalletWireCalls_1.default[callCode]; // calls is enum
|
|
36
36
|
if (!callName) {
|
|
37
37
|
// Invalid call code
|
|
38
38
|
throw new Error(`Invalid call code: ${callCode}`);
|
|
@@ -40,17 +40,17 @@ class WalletWireProcessor {
|
|
|
40
40
|
// Read originator length
|
|
41
41
|
const originatorLength = messageReader.readUInt8();
|
|
42
42
|
const originatorBytes = messageReader.read(originatorLength);
|
|
43
|
-
const originator =
|
|
43
|
+
const originator = index_1.Utils.toUTF8(originatorBytes);
|
|
44
44
|
// Read parameters
|
|
45
45
|
const paramsReader = messageReader; // Remaining bytes
|
|
46
46
|
switch (callName) {
|
|
47
|
-
case
|
|
47
|
+
case "createAction":
|
|
48
48
|
// Deserialize parameters from paramsReader
|
|
49
49
|
const args = {};
|
|
50
50
|
// Read description
|
|
51
51
|
const descriptionLength = paramsReader.readVarIntNum();
|
|
52
52
|
const descriptionBytes = paramsReader.read(descriptionLength);
|
|
53
|
-
args.description =
|
|
53
|
+
args.description = index_1.Utils.toUTF8(descriptionBytes);
|
|
54
54
|
// tx
|
|
55
55
|
const inputBeefLength = paramsReader.readVarIntNum();
|
|
56
56
|
if (inputBeefLength >= 0) {
|
|
@@ -71,7 +71,7 @@ class WalletWireProcessor {
|
|
|
71
71
|
const unlockingScriptLength = paramsReader.readVarIntNum();
|
|
72
72
|
if (unlockingScriptLength >= 0) {
|
|
73
73
|
const unlockingScriptBytes = paramsReader.read(unlockingScriptLength);
|
|
74
|
-
input.unlockingScript =
|
|
74
|
+
input.unlockingScript = index_1.Utils.toHex(unlockingScriptBytes);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
input.unlockingScript = undefined;
|
|
@@ -81,7 +81,7 @@ class WalletWireProcessor {
|
|
|
81
81
|
// inputDescription
|
|
82
82
|
const inputDescriptionLength = paramsReader.readVarIntNum();
|
|
83
83
|
const inputDescriptionBytes = paramsReader.read(inputDescriptionLength);
|
|
84
|
-
input.inputDescription =
|
|
84
|
+
input.inputDescription = index_1.Utils.toUTF8(inputDescriptionBytes);
|
|
85
85
|
// sequenceNumber
|
|
86
86
|
const sequenceNumber = paramsReader.readVarIntNum();
|
|
87
87
|
if (sequenceNumber >= 0) {
|
|
@@ -105,18 +105,18 @@ class WalletWireProcessor {
|
|
|
105
105
|
// lockingScript
|
|
106
106
|
const lockingScriptLength = paramsReader.readVarIntNum();
|
|
107
107
|
const lockingScriptBytes = paramsReader.read(lockingScriptLength);
|
|
108
|
-
output.lockingScript =
|
|
108
|
+
output.lockingScript = index_1.Utils.toHex(lockingScriptBytes);
|
|
109
109
|
// satoshis
|
|
110
110
|
output.satoshis = paramsReader.readVarIntNum();
|
|
111
111
|
// outputDescription
|
|
112
112
|
const outputDescriptionLength = paramsReader.readVarIntNum();
|
|
113
113
|
const outputDescriptionBytes = paramsReader.read(outputDescriptionLength);
|
|
114
|
-
output.outputDescription =
|
|
114
|
+
output.outputDescription = index_1.Utils.toUTF8(outputDescriptionBytes);
|
|
115
115
|
// basket
|
|
116
116
|
const basketLength = paramsReader.readVarIntNum();
|
|
117
117
|
if (basketLength >= 0) {
|
|
118
118
|
const basketBytes = paramsReader.read(basketLength);
|
|
119
|
-
output.basket =
|
|
119
|
+
output.basket = index_1.Utils.toUTF8(basketBytes);
|
|
120
120
|
}
|
|
121
121
|
else {
|
|
122
122
|
output.basket = undefined;
|
|
@@ -125,7 +125,7 @@ class WalletWireProcessor {
|
|
|
125
125
|
const customInstructionsLength = paramsReader.readVarIntNum();
|
|
126
126
|
if (customInstructionsLength >= 0) {
|
|
127
127
|
const customInstructionsBytes = paramsReader.read(customInstructionsLength);
|
|
128
|
-
output.customInstructions =
|
|
128
|
+
output.customInstructions = index_1.Utils.toUTF8(customInstructionsBytes);
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
131
|
output.customInstructions = undefined;
|
|
@@ -137,7 +137,7 @@ class WalletWireProcessor {
|
|
|
137
137
|
for (let j = 0; j < tagsLength; j++) {
|
|
138
138
|
const tagLength = paramsReader.readVarIntNum();
|
|
139
139
|
const tagBytes = paramsReader.read(tagLength);
|
|
140
|
-
const tag =
|
|
140
|
+
const tag = index_1.Utils.toUTF8(tagBytes);
|
|
141
141
|
output.tags.push(tag);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -173,7 +173,7 @@ class WalletWireProcessor {
|
|
|
173
173
|
for (let i = 0; i < labelsLength; i++) {
|
|
174
174
|
const labelLength = paramsReader.readVarIntNum();
|
|
175
175
|
const labelBytes = paramsReader.read(labelLength);
|
|
176
|
-
const label =
|
|
176
|
+
const label = index_1.Utils.toUTF8(labelBytes);
|
|
177
177
|
args.labels.push(label);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
@@ -198,7 +198,8 @@ class WalletWireProcessor {
|
|
|
198
198
|
args.options.acceptDelayedBroadcast = undefined;
|
|
199
199
|
}
|
|
200
200
|
else {
|
|
201
|
-
args.options.acceptDelayedBroadcast =
|
|
201
|
+
args.options.acceptDelayedBroadcast =
|
|
202
|
+
acceptDelayedBroadcastFlag === 1;
|
|
202
203
|
}
|
|
203
204
|
// trustSelf
|
|
204
205
|
const trustSelfFlag = paramsReader.readInt8();
|
|
@@ -206,7 +207,7 @@ class WalletWireProcessor {
|
|
|
206
207
|
args.options.trustSelf = undefined;
|
|
207
208
|
}
|
|
208
209
|
else if (trustSelfFlag === 1) {
|
|
209
|
-
args.options.trustSelf =
|
|
210
|
+
args.options.trustSelf = "known";
|
|
210
211
|
}
|
|
211
212
|
// knownTxids
|
|
212
213
|
const knownTxidsLength = paramsReader.readVarIntNum();
|
|
@@ -214,7 +215,7 @@ class WalletWireProcessor {
|
|
|
214
215
|
args.options.knownTxids = [];
|
|
215
216
|
for (let i = 0; i < knownTxidsLength; i++) {
|
|
216
217
|
const txidBytes = paramsReader.read(32);
|
|
217
|
-
const txid =
|
|
218
|
+
const txid = index_1.Utils.toHex(txidBytes);
|
|
218
219
|
args.options.knownTxids.push(txid);
|
|
219
220
|
}
|
|
220
221
|
}
|
|
@@ -255,7 +256,7 @@ class WalletWireProcessor {
|
|
|
255
256
|
args.options.sendWith = [];
|
|
256
257
|
for (let i = 0; i < sendWithLength; i++) {
|
|
257
258
|
const txidBytes = paramsReader.read(32);
|
|
258
|
-
const txid =
|
|
259
|
+
const txid = index_1.Utils.toHex(txidBytes);
|
|
259
260
|
args.options.sendWith.push(txid);
|
|
260
261
|
}
|
|
261
262
|
}
|
|
@@ -277,11 +278,11 @@ class WalletWireProcessor {
|
|
|
277
278
|
// Call the method
|
|
278
279
|
const createActionResult = await this.wallet.createAction(args, originator);
|
|
279
280
|
// Serialize the result
|
|
280
|
-
const resultWriter = new
|
|
281
|
+
const resultWriter = new index_1.Utils.Writer();
|
|
281
282
|
// txid
|
|
282
283
|
if (createActionResult.txid) {
|
|
283
284
|
resultWriter.writeInt8(1);
|
|
284
|
-
resultWriter.write(
|
|
285
|
+
resultWriter.write(index_1.Utils.toArray(createActionResult.txid, "hex"));
|
|
285
286
|
}
|
|
286
287
|
else {
|
|
287
288
|
resultWriter.writeInt8(0);
|
|
@@ -309,13 +310,13 @@ class WalletWireProcessor {
|
|
|
309
310
|
if (createActionResult.sendWithResults) {
|
|
310
311
|
resultWriter.writeVarIntNum(createActionResult.sendWithResults.length);
|
|
311
312
|
for (const result of createActionResult.sendWithResults) {
|
|
312
|
-
resultWriter.write(
|
|
313
|
+
resultWriter.write(index_1.Utils.toArray(result.txid, "hex"));
|
|
313
314
|
let statusCode;
|
|
314
|
-
if (result.status ===
|
|
315
|
+
if (result.status === "unproven")
|
|
315
316
|
statusCode = 1;
|
|
316
|
-
else if (result.status ===
|
|
317
|
+
else if (result.status === "sending")
|
|
317
318
|
statusCode = 2;
|
|
318
|
-
else if (result.status ===
|
|
319
|
+
else if (result.status === "failed")
|
|
319
320
|
statusCode = 3;
|
|
320
321
|
resultWriter.writeInt8(statusCode);
|
|
321
322
|
}
|
|
@@ -328,7 +329,7 @@ class WalletWireProcessor {
|
|
|
328
329
|
resultWriter.writeInt8(1);
|
|
329
330
|
resultWriter.writeVarIntNum(createActionResult.signableTransaction.tx.length);
|
|
330
331
|
resultWriter.write(createActionResult.signableTransaction.tx);
|
|
331
|
-
const referenceBytes =
|
|
332
|
+
const referenceBytes = index_1.Utils.toArray(createActionResult.signableTransaction.reference, "base64");
|
|
332
333
|
resultWriter.writeVarIntNum(referenceBytes.length);
|
|
333
334
|
resultWriter.write(referenceBytes);
|
|
334
335
|
}
|
|
@@ -336,927 +337,635 @@ class WalletWireProcessor {
|
|
|
336
337
|
resultWriter.writeInt8(0);
|
|
337
338
|
}
|
|
338
339
|
// Return success code and result
|
|
339
|
-
const responseWriter = new
|
|
340
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
340
341
|
responseWriter.writeUInt8(0); // errorByte = 0
|
|
341
342
|
responseWriter.write(resultWriter.toArray());
|
|
342
343
|
return responseWriter.toArray();
|
|
343
|
-
case
|
|
344
|
-
{
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
spend.sequenceNumber = sequenceNumber;
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
spend.sequenceNumber = undefined;
|
|
363
|
-
}
|
|
364
|
-
args.spends[inputIndex] = spend;
|
|
365
|
-
}
|
|
366
|
-
// Deserialize reference
|
|
367
|
-
const referenceLength = paramsReader.readVarIntNum();
|
|
368
|
-
const referenceBytes = paramsReader.read(referenceLength);
|
|
369
|
-
args.reference = index_js_1.Utils.toBase64(referenceBytes);
|
|
370
|
-
// Deserialize options
|
|
371
|
-
const optionsPresent = paramsReader.readInt8();
|
|
372
|
-
if (optionsPresent === 1) {
|
|
373
|
-
args.options = {};
|
|
374
|
-
// acceptDelayedBroadcast
|
|
375
|
-
const acceptDelayedBroadcastFlag = paramsReader.readInt8();
|
|
376
|
-
if (acceptDelayedBroadcastFlag === -1) {
|
|
377
|
-
args.options.acceptDelayedBroadcast = undefined;
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
args.options.acceptDelayedBroadcast = acceptDelayedBroadcastFlag === 1;
|
|
381
|
-
}
|
|
382
|
-
// returnTXIDOnly
|
|
383
|
-
const returnTXIDOnlyFlag = paramsReader.readInt8();
|
|
384
|
-
if (returnTXIDOnlyFlag === -1) {
|
|
385
|
-
args.options.returnTXIDOnly = undefined;
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
args.options.returnTXIDOnly = returnTXIDOnlyFlag === 1;
|
|
389
|
-
}
|
|
390
|
-
// noSend
|
|
391
|
-
const noSendFlag = paramsReader.readInt8();
|
|
392
|
-
if (noSendFlag === -1) {
|
|
393
|
-
args.options.noSend = undefined;
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
args.options.noSend = noSendFlag === 1;
|
|
397
|
-
}
|
|
398
|
-
// sendWith
|
|
399
|
-
const sendWithLength = paramsReader.readVarIntNum();
|
|
400
|
-
if (sendWithLength >= 0) {
|
|
401
|
-
args.options.sendWith = [];
|
|
402
|
-
for (let i = 0; i < sendWithLength; i++) {
|
|
403
|
-
const txidBytes = paramsReader.read(32);
|
|
404
|
-
const txid = index_js_1.Utils.toHex(txidBytes);
|
|
405
|
-
args.options.sendWith.push(txid);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
args.options.sendWith = undefined;
|
|
410
|
-
}
|
|
344
|
+
case "signAction": {
|
|
345
|
+
const args = {};
|
|
346
|
+
// Deserialize spends
|
|
347
|
+
const spendCount = paramsReader.readVarIntNum();
|
|
348
|
+
args.spends = {};
|
|
349
|
+
for (let i = 0; i < spendCount; i++) {
|
|
350
|
+
const inputIndex = paramsReader.readVarIntNum();
|
|
351
|
+
const spend = {};
|
|
352
|
+
// unlockingScript
|
|
353
|
+
const unlockingScriptLength = paramsReader.readVarIntNum();
|
|
354
|
+
const unlockingScriptBytes = paramsReader.read(unlockingScriptLength);
|
|
355
|
+
spend.unlockingScript = index_1.Utils.toHex(unlockingScriptBytes);
|
|
356
|
+
// sequenceNumber
|
|
357
|
+
const sequenceNumber = paramsReader.readVarIntNum();
|
|
358
|
+
if (sequenceNumber >= 0) {
|
|
359
|
+
spend.sequenceNumber = sequenceNumber;
|
|
411
360
|
}
|
|
412
361
|
else {
|
|
413
|
-
|
|
362
|
+
spend.sequenceNumber = undefined;
|
|
414
363
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
364
|
+
args.spends[inputIndex] = spend;
|
|
365
|
+
}
|
|
366
|
+
// Deserialize reference
|
|
367
|
+
const referenceLength = paramsReader.readVarIntNum();
|
|
368
|
+
const referenceBytes = paramsReader.read(referenceLength);
|
|
369
|
+
args.reference = index_1.Utils.toBase64(referenceBytes);
|
|
370
|
+
// Deserialize options
|
|
371
|
+
const optionsPresent = paramsReader.readInt8();
|
|
372
|
+
if (optionsPresent === 1) {
|
|
373
|
+
args.options = {};
|
|
374
|
+
// acceptDelayedBroadcast
|
|
375
|
+
const acceptDelayedBroadcastFlag = paramsReader.readInt8();
|
|
376
|
+
if (acceptDelayedBroadcastFlag === -1) {
|
|
377
|
+
args.options.acceptDelayedBroadcast = undefined;
|
|
423
378
|
}
|
|
424
379
|
else {
|
|
425
|
-
|
|
380
|
+
args.options.acceptDelayedBroadcast =
|
|
381
|
+
acceptDelayedBroadcastFlag === 1;
|
|
426
382
|
}
|
|
427
|
-
//
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
resultWriter.write(signActionResult.tx);
|
|
383
|
+
// returnTXIDOnly
|
|
384
|
+
const returnTXIDOnlyFlag = paramsReader.readInt8();
|
|
385
|
+
if (returnTXIDOnlyFlag === -1) {
|
|
386
|
+
args.options.returnTXIDOnly = undefined;
|
|
432
387
|
}
|
|
433
388
|
else {
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
//
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
resultWriter.write(index_js_1.Utils.toArray(result.txid, 'hex'));
|
|
441
|
-
let statusCode;
|
|
442
|
-
if (result.status === 'unproven')
|
|
443
|
-
statusCode = 1;
|
|
444
|
-
else if (result.status === 'sending')
|
|
445
|
-
statusCode = 2;
|
|
446
|
-
else if (result.status === 'failed')
|
|
447
|
-
statusCode = 3;
|
|
448
|
-
resultWriter.writeInt8(statusCode);
|
|
449
|
-
}
|
|
389
|
+
args.options.returnTXIDOnly = returnTXIDOnlyFlag === 1;
|
|
390
|
+
}
|
|
391
|
+
// noSend
|
|
392
|
+
const noSendFlag = paramsReader.readInt8();
|
|
393
|
+
if (noSendFlag === -1) {
|
|
394
|
+
args.options.noSend = undefined;
|
|
450
395
|
}
|
|
451
396
|
else {
|
|
452
|
-
|
|
397
|
+
args.options.noSend = noSendFlag === 1;
|
|
453
398
|
}
|
|
454
|
-
//
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
// Deserialize reference
|
|
463
|
-
const referenceBytes = paramsReader.read();
|
|
464
|
-
const reference = index_js_1.Utils.toBase64(referenceBytes);
|
|
465
|
-
// Call the method
|
|
466
|
-
await this.wallet.abortAction({ reference }, originator);
|
|
467
|
-
// Return success code and result
|
|
468
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
469
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
470
|
-
return responseWriter.toArray();
|
|
471
|
-
}
|
|
472
|
-
case 'listActions':
|
|
473
|
-
{
|
|
474
|
-
const args = {};
|
|
475
|
-
// Deserialize labels
|
|
476
|
-
const labelsLength = paramsReader.readVarIntNum();
|
|
477
|
-
args.labels = [];
|
|
478
|
-
for (let i = 0; i < labelsLength; i++) {
|
|
479
|
-
const labelLength = paramsReader.readVarIntNum();
|
|
480
|
-
const labelBytes = paramsReader.read(labelLength);
|
|
481
|
-
args.labels.push(index_js_1.Utils.toUTF8(labelBytes));
|
|
482
|
-
}
|
|
483
|
-
// Deserialize labelQueryMode
|
|
484
|
-
const labelQueryModeFlag = paramsReader.readInt8();
|
|
485
|
-
if (labelQueryModeFlag === -1) {
|
|
486
|
-
args.labelQueryMode = undefined;
|
|
487
|
-
}
|
|
488
|
-
else if (labelQueryModeFlag === 1) {
|
|
489
|
-
args.labelQueryMode = 'any';
|
|
490
|
-
}
|
|
491
|
-
else if (labelQueryModeFlag === 2) {
|
|
492
|
-
args.labelQueryMode = 'all';
|
|
493
|
-
}
|
|
494
|
-
// Deserialize include options
|
|
495
|
-
const includeOptionsNames = [
|
|
496
|
-
'includeLabels',
|
|
497
|
-
'includeInputs',
|
|
498
|
-
'includeInputSourceLockingScripts',
|
|
499
|
-
'includeInputUnlockingScripts',
|
|
500
|
-
'includeOutputs',
|
|
501
|
-
'includeOutputLockingScripts'
|
|
502
|
-
];
|
|
503
|
-
for (const optionName of includeOptionsNames) {
|
|
504
|
-
const optionFlag = paramsReader.readInt8();
|
|
505
|
-
if (optionFlag === -1) {
|
|
506
|
-
args[optionName] = undefined;
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
509
|
-
args[optionName] = optionFlag === 1;
|
|
399
|
+
// sendWith
|
|
400
|
+
const sendWithLength = paramsReader.readVarIntNum();
|
|
401
|
+
if (sendWithLength >= 0) {
|
|
402
|
+
args.options.sendWith = [];
|
|
403
|
+
for (let i = 0; i < sendWithLength; i++) {
|
|
404
|
+
const txidBytes = paramsReader.read(32);
|
|
405
|
+
const txid = index_1.Utils.toHex(txidBytes);
|
|
406
|
+
args.options.sendWith.push(txid);
|
|
510
407
|
}
|
|
511
408
|
}
|
|
512
|
-
// Deserialize limit
|
|
513
|
-
const limit = paramsReader.readVarIntNum();
|
|
514
|
-
if (limit >= 0) {
|
|
515
|
-
args.limit = limit;
|
|
516
|
-
}
|
|
517
409
|
else {
|
|
518
|
-
args.
|
|
410
|
+
args.options.sendWith = undefined;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
args.options = undefined;
|
|
415
|
+
}
|
|
416
|
+
// Call the method
|
|
417
|
+
const signActionResult = await this.wallet.signAction(args, originator);
|
|
418
|
+
// Serialize the result
|
|
419
|
+
const resultWriter = new index_1.Utils.Writer();
|
|
420
|
+
// txid
|
|
421
|
+
if (signActionResult.txid) {
|
|
422
|
+
resultWriter.writeInt8(1);
|
|
423
|
+
resultWriter.write(index_1.Utils.toArray(signActionResult.txid, "hex"));
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
resultWriter.writeInt8(0);
|
|
427
|
+
}
|
|
428
|
+
// tx
|
|
429
|
+
if (signActionResult.tx) {
|
|
430
|
+
resultWriter.writeInt8(1);
|
|
431
|
+
resultWriter.writeVarIntNum(signActionResult.tx.length);
|
|
432
|
+
resultWriter.write(signActionResult.tx);
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
resultWriter.writeInt8(0);
|
|
436
|
+
}
|
|
437
|
+
// sendWithResults
|
|
438
|
+
if (signActionResult.sendWithResults) {
|
|
439
|
+
resultWriter.writeVarIntNum(signActionResult.sendWithResults.length);
|
|
440
|
+
for (const result of signActionResult.sendWithResults) {
|
|
441
|
+
resultWriter.write(index_1.Utils.toArray(result.txid, "hex"));
|
|
442
|
+
let statusCode;
|
|
443
|
+
if (result.status === "unproven")
|
|
444
|
+
statusCode = 1;
|
|
445
|
+
else if (result.status === "sending")
|
|
446
|
+
statusCode = 2;
|
|
447
|
+
else if (result.status === "failed")
|
|
448
|
+
statusCode = 3;
|
|
449
|
+
resultWriter.writeInt8(statusCode);
|
|
519
450
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
resultWriter.writeVarIntNum(-1);
|
|
454
|
+
}
|
|
455
|
+
// Return success code and result
|
|
456
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
457
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
458
|
+
responseWriter.write(resultWriter.toArray());
|
|
459
|
+
return responseWriter.toArray();
|
|
460
|
+
}
|
|
461
|
+
case "abortAction": {
|
|
462
|
+
// Deserialize reference
|
|
463
|
+
const referenceBytes = paramsReader.read();
|
|
464
|
+
const reference = index_1.Utils.toBase64(referenceBytes);
|
|
465
|
+
// Call the method
|
|
466
|
+
await this.wallet.abortAction({ reference }, originator);
|
|
467
|
+
// Return success code and result
|
|
468
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
469
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
470
|
+
return responseWriter.toArray();
|
|
471
|
+
}
|
|
472
|
+
case "listActions": {
|
|
473
|
+
const args = {};
|
|
474
|
+
// Deserialize labels
|
|
475
|
+
const labelsLength = paramsReader.readVarIntNum();
|
|
476
|
+
args.labels = [];
|
|
477
|
+
for (let i = 0; i < labelsLength; i++) {
|
|
478
|
+
const labelLength = paramsReader.readVarIntNum();
|
|
479
|
+
const labelBytes = paramsReader.read(labelLength);
|
|
480
|
+
args.labels.push(index_1.Utils.toUTF8(labelBytes));
|
|
481
|
+
}
|
|
482
|
+
// Deserialize labelQueryMode
|
|
483
|
+
const labelQueryModeFlag = paramsReader.readInt8();
|
|
484
|
+
if (labelQueryModeFlag === -1) {
|
|
485
|
+
args.labelQueryMode = undefined;
|
|
486
|
+
}
|
|
487
|
+
else if (labelQueryModeFlag === 1) {
|
|
488
|
+
args.labelQueryMode = "any";
|
|
489
|
+
}
|
|
490
|
+
else if (labelQueryModeFlag === 2) {
|
|
491
|
+
args.labelQueryMode = "all";
|
|
492
|
+
}
|
|
493
|
+
// Deserialize include options
|
|
494
|
+
const includeOptionsNames = [
|
|
495
|
+
"includeLabels",
|
|
496
|
+
"includeInputs",
|
|
497
|
+
"includeInputSourceLockingScripts",
|
|
498
|
+
"includeInputUnlockingScripts",
|
|
499
|
+
"includeOutputs",
|
|
500
|
+
"includeOutputLockingScripts",
|
|
501
|
+
];
|
|
502
|
+
for (const optionName of includeOptionsNames) {
|
|
503
|
+
const optionFlag = paramsReader.readInt8();
|
|
504
|
+
if (optionFlag === -1) {
|
|
505
|
+
args[optionName] = undefined;
|
|
524
506
|
}
|
|
525
507
|
else {
|
|
526
|
-
args
|
|
508
|
+
args[optionName] = optionFlag === 1;
|
|
527
509
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
510
|
+
}
|
|
511
|
+
// Deserialize limit
|
|
512
|
+
const limit = paramsReader.readVarIntNum();
|
|
513
|
+
if (limit >= 0) {
|
|
514
|
+
args.limit = limit;
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
args.limit = undefined;
|
|
518
|
+
}
|
|
519
|
+
// Deserialize offset
|
|
520
|
+
const offset = paramsReader.readVarIntNum();
|
|
521
|
+
if (offset >= 0) {
|
|
522
|
+
args.offset = offset;
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
args.offset = undefined;
|
|
526
|
+
}
|
|
527
|
+
// Deserialize seekPermission
|
|
528
|
+
const seekPermission = paramsReader.readInt8();
|
|
529
|
+
if (seekPermission >= 0) {
|
|
530
|
+
args.seekPermission = seekPermission === 1;
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
args.seekPermission = undefined;
|
|
534
|
+
}
|
|
535
|
+
// Call the method
|
|
536
|
+
const listActionsResult = await this.wallet.listActions(args, originator);
|
|
537
|
+
// Serialize the result
|
|
538
|
+
const resultWriter = new index_1.Utils.Writer();
|
|
539
|
+
// totalActions
|
|
540
|
+
resultWriter.writeVarIntNum(listActionsResult.totalActions);
|
|
541
|
+
// actions
|
|
542
|
+
for (const action of listActionsResult.actions) {
|
|
543
|
+
// txid
|
|
544
|
+
resultWriter.write(index_1.Utils.toArray(action.txid, "hex"));
|
|
545
|
+
// satoshis
|
|
546
|
+
resultWriter.writeVarIntNum(action.satoshis);
|
|
547
|
+
// status
|
|
548
|
+
let statusCode;
|
|
549
|
+
switch (action.status) {
|
|
550
|
+
case "completed":
|
|
551
|
+
statusCode = 1;
|
|
552
|
+
break;
|
|
553
|
+
case "unprocessed":
|
|
554
|
+
statusCode = 2;
|
|
555
|
+
break;
|
|
556
|
+
case "sending":
|
|
557
|
+
statusCode = 3;
|
|
558
|
+
break;
|
|
559
|
+
case "unproven":
|
|
560
|
+
statusCode = 4;
|
|
561
|
+
break;
|
|
562
|
+
case "unsigned":
|
|
563
|
+
statusCode = 5;
|
|
564
|
+
break;
|
|
565
|
+
case "nosend":
|
|
566
|
+
statusCode = 6;
|
|
567
|
+
break;
|
|
568
|
+
case "nonfinal":
|
|
569
|
+
statusCode = 7;
|
|
570
|
+
break;
|
|
571
|
+
default:
|
|
572
|
+
statusCode = -1;
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
resultWriter.writeInt8(statusCode);
|
|
576
|
+
// isOutgoing
|
|
577
|
+
resultWriter.writeInt8(action.isOutgoing ? 1 : 0);
|
|
578
|
+
// description
|
|
579
|
+
const descriptionBytes = index_1.Utils.toArray(action.description, "utf8");
|
|
580
|
+
resultWriter.writeVarIntNum(descriptionBytes.length);
|
|
581
|
+
resultWriter.write(descriptionBytes);
|
|
582
|
+
// labels
|
|
583
|
+
if (action.labels !== undefined) {
|
|
584
|
+
resultWriter.writeVarIntNum(action.labels.length);
|
|
585
|
+
for (const label of action.labels) {
|
|
586
|
+
const labelBytes = index_1.Utils.toArray(label, "utf8");
|
|
587
|
+
resultWriter.writeVarIntNum(labelBytes.length);
|
|
588
|
+
resultWriter.write(labelBytes);
|
|
589
|
+
}
|
|
532
590
|
}
|
|
533
591
|
else {
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
//
|
|
537
|
-
|
|
538
|
-
//
|
|
539
|
-
|
|
540
|
-
//
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
break;
|
|
554
|
-
case 'unprocessed':
|
|
555
|
-
statusCode = 2;
|
|
556
|
-
break;
|
|
557
|
-
case 'sending':
|
|
558
|
-
statusCode = 3;
|
|
559
|
-
break;
|
|
560
|
-
case 'unproven':
|
|
561
|
-
statusCode = 4;
|
|
562
|
-
break;
|
|
563
|
-
case 'unsigned':
|
|
564
|
-
statusCode = 5;
|
|
565
|
-
break;
|
|
566
|
-
case 'nosend':
|
|
567
|
-
statusCode = 6;
|
|
568
|
-
break;
|
|
569
|
-
case 'nonfinal':
|
|
570
|
-
statusCode = 7;
|
|
571
|
-
break;
|
|
572
|
-
default:
|
|
573
|
-
statusCode = -1;
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
resultWriter.writeInt8(statusCode);
|
|
577
|
-
// isOutgoing
|
|
578
|
-
resultWriter.writeInt8(action.isOutgoing ? 1 : 0);
|
|
579
|
-
// description
|
|
580
|
-
const descriptionBytes = index_js_1.Utils.toArray(action.description, 'utf8');
|
|
581
|
-
resultWriter.writeVarIntNum(descriptionBytes.length);
|
|
582
|
-
resultWriter.write(descriptionBytes);
|
|
583
|
-
// labels
|
|
584
|
-
if (action.labels !== undefined) {
|
|
585
|
-
resultWriter.writeVarIntNum(action.labels.length);
|
|
586
|
-
for (const label of action.labels) {
|
|
587
|
-
const labelBytes = index_js_1.Utils.toArray(label, 'utf8');
|
|
588
|
-
resultWriter.writeVarIntNum(labelBytes.length);
|
|
589
|
-
resultWriter.write(labelBytes);
|
|
592
|
+
resultWriter.writeVarIntNum(-1);
|
|
593
|
+
}
|
|
594
|
+
// version
|
|
595
|
+
resultWriter.writeVarIntNum(action.version);
|
|
596
|
+
// lockTime
|
|
597
|
+
resultWriter.writeVarIntNum(action.lockTime);
|
|
598
|
+
// inputs
|
|
599
|
+
if (action.inputs !== undefined) {
|
|
600
|
+
resultWriter.writeVarIntNum(action.inputs.length);
|
|
601
|
+
for (const input of action.inputs) {
|
|
602
|
+
// sourceOutpoint
|
|
603
|
+
resultWriter.write(this.encodeOutpoint(input.sourceOutpoint));
|
|
604
|
+
// sourceSatoshis
|
|
605
|
+
resultWriter.writeVarIntNum(input.sourceSatoshis);
|
|
606
|
+
// sourceLockingScript
|
|
607
|
+
if (input.sourceLockingScript !== undefined) {
|
|
608
|
+
const sourceLockingScriptBytes = index_1.Utils.toArray(input.sourceLockingScript, "hex");
|
|
609
|
+
resultWriter.writeVarIntNum(sourceLockingScriptBytes.length);
|
|
610
|
+
resultWriter.write(sourceLockingScriptBytes);
|
|
590
611
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
resultWriter.writeVarIntNum(-1);
|
|
594
|
-
}
|
|
595
|
-
// version
|
|
596
|
-
resultWriter.writeVarIntNum(action.version);
|
|
597
|
-
// lockTime
|
|
598
|
-
resultWriter.writeVarIntNum(action.lockTime);
|
|
599
|
-
// inputs
|
|
600
|
-
if (action.inputs !== undefined) {
|
|
601
|
-
resultWriter.writeVarIntNum(action.inputs.length);
|
|
602
|
-
for (const input of action.inputs) {
|
|
603
|
-
// sourceOutpoint
|
|
604
|
-
resultWriter.write(this.encodeOutpoint(input.sourceOutpoint));
|
|
605
|
-
// sourceSatoshis
|
|
606
|
-
resultWriter.writeVarIntNum(input.sourceSatoshis);
|
|
607
|
-
// sourceLockingScript
|
|
608
|
-
if (input.sourceLockingScript !== undefined) {
|
|
609
|
-
const sourceLockingScriptBytes = index_js_1.Utils.toArray(input.sourceLockingScript, 'hex');
|
|
610
|
-
resultWriter.writeVarIntNum(sourceLockingScriptBytes.length);
|
|
611
|
-
resultWriter.write(sourceLockingScriptBytes);
|
|
612
|
-
}
|
|
613
|
-
else {
|
|
614
|
-
resultWriter.writeVarIntNum(-1);
|
|
615
|
-
}
|
|
616
|
-
// unlockingScript
|
|
617
|
-
if (input.unlockingScript !== undefined) {
|
|
618
|
-
const unlockingScriptBytes = index_js_1.Utils.toArray(input.unlockingScript, 'hex');
|
|
619
|
-
resultWriter.writeVarIntNum(unlockingScriptBytes.length);
|
|
620
|
-
resultWriter.write(unlockingScriptBytes);
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
resultWriter.writeVarIntNum(-1);
|
|
624
|
-
}
|
|
625
|
-
// inputDescription
|
|
626
|
-
const inputDescriptionBytes = index_js_1.Utils.toArray(input.inputDescription, 'utf8');
|
|
627
|
-
resultWriter.writeVarIntNum(inputDescriptionBytes.length);
|
|
628
|
-
resultWriter.write(inputDescriptionBytes);
|
|
629
|
-
// sequenceNumber
|
|
630
|
-
resultWriter.writeVarIntNum(input.sequenceNumber);
|
|
612
|
+
else {
|
|
613
|
+
resultWriter.writeVarIntNum(-1);
|
|
631
614
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
if (action.outputs !== undefined) {
|
|
638
|
-
resultWriter.writeVarIntNum(action.outputs.length);
|
|
639
|
-
for (const output of action.outputs) {
|
|
640
|
-
// outputIndex
|
|
641
|
-
resultWriter.writeVarIntNum(output.outputIndex);
|
|
642
|
-
// satoshis
|
|
643
|
-
resultWriter.writeVarIntNum(output.satoshis);
|
|
644
|
-
// lockingScript
|
|
645
|
-
if (output.lockingScript !== undefined) {
|
|
646
|
-
const lockingScriptBytes = index_js_1.Utils.toArray(output.lockingScript, 'hex');
|
|
647
|
-
resultWriter.writeVarIntNum(lockingScriptBytes.length);
|
|
648
|
-
resultWriter.write(lockingScriptBytes);
|
|
649
|
-
}
|
|
650
|
-
else {
|
|
651
|
-
resultWriter.writeVarIntNum(-1);
|
|
652
|
-
}
|
|
653
|
-
// spendable
|
|
654
|
-
resultWriter.writeInt8(output.spendable ? 1 : 0);
|
|
655
|
-
// outputDescription
|
|
656
|
-
const outputDescriptionBytes = index_js_1.Utils.toArray(output.outputDescription, 'utf8');
|
|
657
|
-
resultWriter.writeVarIntNum(outputDescriptionBytes.length);
|
|
658
|
-
resultWriter.write(outputDescriptionBytes);
|
|
659
|
-
// basket
|
|
660
|
-
if (output.basket !== undefined) {
|
|
661
|
-
const basketBytes = index_js_1.Utils.toArray(output.basket, 'utf8');
|
|
662
|
-
resultWriter.writeVarIntNum(basketBytes.length);
|
|
663
|
-
resultWriter.write(basketBytes);
|
|
664
|
-
}
|
|
665
|
-
else {
|
|
666
|
-
resultWriter.writeVarIntNum(-1);
|
|
667
|
-
}
|
|
668
|
-
// tags
|
|
669
|
-
if (output.tags !== undefined) {
|
|
670
|
-
resultWriter.writeVarIntNum(output.tags.length);
|
|
671
|
-
for (const tag of output.tags) {
|
|
672
|
-
const tagBytes = index_js_1.Utils.toArray(tag, 'utf8');
|
|
673
|
-
resultWriter.writeVarIntNum(tagBytes.length);
|
|
674
|
-
resultWriter.write(tagBytes);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
else {
|
|
678
|
-
resultWriter.writeVarIntNum(-1);
|
|
679
|
-
}
|
|
680
|
-
// customInstructions
|
|
681
|
-
if (output.customInstructions !== undefined) {
|
|
682
|
-
const customInstructionsBytes = index_js_1.Utils.toArray(output.customInstructions, 'utf8');
|
|
683
|
-
resultWriter.writeVarIntNum(customInstructionsBytes.length);
|
|
684
|
-
resultWriter.write(customInstructionsBytes);
|
|
685
|
-
}
|
|
686
|
-
else {
|
|
687
|
-
resultWriter.writeVarIntNum(-1);
|
|
688
|
-
}
|
|
615
|
+
// unlockingScript
|
|
616
|
+
if (input.unlockingScript !== undefined) {
|
|
617
|
+
const unlockingScriptBytes = index_1.Utils.toArray(input.unlockingScript, "hex");
|
|
618
|
+
resultWriter.writeVarIntNum(unlockingScriptBytes.length);
|
|
619
|
+
resultWriter.write(unlockingScriptBytes);
|
|
689
620
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
621
|
+
else {
|
|
622
|
+
resultWriter.writeVarIntNum(-1);
|
|
623
|
+
}
|
|
624
|
+
// inputDescription
|
|
625
|
+
const inputDescriptionBytes = index_1.Utils.toArray(input.inputDescription, "utf8");
|
|
626
|
+
resultWriter.writeVarIntNum(inputDescriptionBytes.length);
|
|
627
|
+
resultWriter.write(inputDescriptionBytes);
|
|
628
|
+
// sequenceNumber
|
|
629
|
+
resultWriter.writeVarIntNum(input.sequenceNumber);
|
|
693
630
|
}
|
|
694
631
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
output.
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
// derivationPrefix
|
|
722
|
-
const derivationPrefixLength = paramsReader.readVarIntNum();
|
|
723
|
-
const derivationPrefixBytes = paramsReader.read(derivationPrefixLength);
|
|
724
|
-
output.paymentRemittance.derivationPrefix = index_js_1.Utils.toBase64(derivationPrefixBytes);
|
|
725
|
-
// derivationSuffix
|
|
726
|
-
const derivationSuffixLength = paramsReader.readVarIntNum();
|
|
727
|
-
const derivationSuffixBytes = paramsReader.read(derivationSuffixLength);
|
|
728
|
-
output.paymentRemittance.derivationSuffix = index_js_1.Utils.toBase64(derivationSuffixBytes);
|
|
729
|
-
}
|
|
730
|
-
else if (protocolFlag === 2) {
|
|
731
|
-
output.protocol = 'basket insertion';
|
|
732
|
-
output.insertionRemittance = {};
|
|
632
|
+
else {
|
|
633
|
+
resultWriter.writeVarIntNum(-1);
|
|
634
|
+
}
|
|
635
|
+
// outputs
|
|
636
|
+
if (action.outputs !== undefined) {
|
|
637
|
+
resultWriter.writeVarIntNum(action.outputs.length);
|
|
638
|
+
for (const output of action.outputs) {
|
|
639
|
+
// outputIndex
|
|
640
|
+
resultWriter.writeVarIntNum(output.outputIndex);
|
|
641
|
+
// satoshis
|
|
642
|
+
resultWriter.writeVarIntNum(output.satoshis);
|
|
643
|
+
// lockingScript
|
|
644
|
+
if (output.lockingScript !== undefined) {
|
|
645
|
+
const lockingScriptBytes = index_1.Utils.toArray(output.lockingScript, "hex");
|
|
646
|
+
resultWriter.writeVarIntNum(lockingScriptBytes.length);
|
|
647
|
+
resultWriter.write(lockingScriptBytes);
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
resultWriter.writeVarIntNum(-1);
|
|
651
|
+
}
|
|
652
|
+
// spendable
|
|
653
|
+
resultWriter.writeInt8(output.spendable ? 1 : 0);
|
|
654
|
+
// outputDescription
|
|
655
|
+
const outputDescriptionBytes = index_1.Utils.toArray(output.outputDescription, "utf8");
|
|
656
|
+
resultWriter.writeVarIntNum(outputDescriptionBytes.length);
|
|
657
|
+
resultWriter.write(outputDescriptionBytes);
|
|
733
658
|
// basket
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
output.insertionRemittance.customInstructions = index_js_1.Utils.toUTF8(customInstructionsBytes);
|
|
659
|
+
if (output.basket !== undefined) {
|
|
660
|
+
const basketBytes = index_1.Utils.toArray(output.basket, "utf8");
|
|
661
|
+
resultWriter.writeVarIntNum(basketBytes.length);
|
|
662
|
+
resultWriter.write(basketBytes);
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
resultWriter.writeVarIntNum(-1);
|
|
742
666
|
}
|
|
743
667
|
// tags
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
output.
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
output.insertionRemittance.tags.push(index_js_1.Utils.toUTF8(tagBytes));
|
|
668
|
+
if (output.tags !== undefined) {
|
|
669
|
+
resultWriter.writeVarIntNum(output.tags.length);
|
|
670
|
+
for (const tag of output.tags) {
|
|
671
|
+
const tagBytes = index_1.Utils.toArray(tag, "utf8");
|
|
672
|
+
resultWriter.writeVarIntNum(tagBytes.length);
|
|
673
|
+
resultWriter.write(tagBytes);
|
|
751
674
|
}
|
|
752
675
|
}
|
|
753
676
|
else {
|
|
754
|
-
|
|
677
|
+
resultWriter.writeVarIntNum(-1);
|
|
678
|
+
}
|
|
679
|
+
// customInstructions
|
|
680
|
+
if (output.customInstructions !== undefined) {
|
|
681
|
+
const customInstructionsBytes = index_1.Utils.toArray(output.customInstructions, "utf8");
|
|
682
|
+
resultWriter.writeVarIntNum(customInstructionsBytes.length);
|
|
683
|
+
resultWriter.write(customInstructionsBytes);
|
|
684
|
+
}
|
|
685
|
+
else {
|
|
686
|
+
resultWriter.writeVarIntNum(-1);
|
|
755
687
|
}
|
|
756
688
|
}
|
|
757
|
-
args.outputs.push(output);
|
|
758
|
-
}
|
|
759
|
-
const numberOfLabels = paramsReader.readVarIntNum();
|
|
760
|
-
if (numberOfLabels >= 0) {
|
|
761
|
-
args.labels = [];
|
|
762
|
-
for (let i = 0; i < numberOfLabels; i++) {
|
|
763
|
-
const labelLength = paramsReader.readVarIntNum();
|
|
764
|
-
args.labels.push(index_js_1.Utils.toUTF8(paramsReader.read(labelLength)));
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
const descriptionLength = paramsReader.readVarIntNum();
|
|
768
|
-
args.description = index_js_1.Utils.toUTF8(paramsReader.read(descriptionLength));
|
|
769
|
-
// Deserialize seekPermission
|
|
770
|
-
const seekPermission = paramsReader.readInt8();
|
|
771
|
-
if (seekPermission >= 0) {
|
|
772
|
-
args.seekPermission = seekPermission === 1;
|
|
773
|
-
}
|
|
774
|
-
else {
|
|
775
|
-
args.seekPermission = undefined;
|
|
776
|
-
}
|
|
777
|
-
// Call the method
|
|
778
|
-
await this.wallet.internalizeAction(args, originator);
|
|
779
|
-
// Return success code and result
|
|
780
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
781
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
782
|
-
return responseWriter.toArray();
|
|
783
|
-
}
|
|
784
|
-
case 'listOutputs':
|
|
785
|
-
{
|
|
786
|
-
const args = {};
|
|
787
|
-
// Deserialize basket
|
|
788
|
-
const basketLength = paramsReader.readVarIntNum();
|
|
789
|
-
const basketBytes = paramsReader.read(basketLength);
|
|
790
|
-
args.basket = index_js_1.Utils.toUTF8(basketBytes);
|
|
791
|
-
// Deserialize tags
|
|
792
|
-
const tagsLength = paramsReader.readVarIntNum();
|
|
793
|
-
if (tagsLength > 0) {
|
|
794
|
-
args.tags = [];
|
|
795
|
-
for (let i = 0; i < tagsLength; i++) {
|
|
796
|
-
const tagLength = paramsReader.readVarIntNum();
|
|
797
|
-
const tagBytes = paramsReader.read(tagLength);
|
|
798
|
-
args.tags.push(index_js_1.Utils.toUTF8(tagBytes));
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
else {
|
|
802
|
-
args.tags = undefined;
|
|
803
|
-
}
|
|
804
|
-
// Deserialize tagQueryMode
|
|
805
|
-
const tagQueryModeFlag = paramsReader.readInt8();
|
|
806
|
-
if (tagQueryModeFlag === 1) {
|
|
807
|
-
args.tagQueryMode = 'all';
|
|
808
|
-
}
|
|
809
|
-
else if (tagQueryModeFlag === 2) {
|
|
810
|
-
args.tagQueryMode = 'any';
|
|
811
689
|
}
|
|
812
690
|
else {
|
|
813
|
-
|
|
691
|
+
resultWriter.writeVarIntNum(-1);
|
|
814
692
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
693
|
+
}
|
|
694
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
695
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
696
|
+
responseWriter.write(resultWriter.toArray());
|
|
697
|
+
return responseWriter.toArray();
|
|
698
|
+
}
|
|
699
|
+
case "internalizeAction": {
|
|
700
|
+
const args = {};
|
|
701
|
+
// Read tx
|
|
702
|
+
const txLength = paramsReader.readVarIntNum();
|
|
703
|
+
args.tx = paramsReader.read(txLength);
|
|
704
|
+
// Read outputs
|
|
705
|
+
const outputsLength = paramsReader.readVarIntNum();
|
|
706
|
+
args.outputs = [];
|
|
707
|
+
for (let i = 0; i < outputsLength; i++) {
|
|
708
|
+
const output = {};
|
|
709
|
+
// outputIndex
|
|
710
|
+
output.outputIndex = paramsReader.readVarIntNum();
|
|
711
|
+
// protocol
|
|
712
|
+
const protocolFlag = paramsReader.readUInt8();
|
|
713
|
+
if (protocolFlag === 1) {
|
|
714
|
+
output.protocol = "wallet payment";
|
|
715
|
+
output.paymentRemittance = {};
|
|
716
|
+
// senderIdentityKey
|
|
717
|
+
const senderIdentityKeyBytes = paramsReader.read(33);
|
|
718
|
+
output.paymentRemittance.senderIdentityKey = index_1.Utils.toHex(senderIdentityKeyBytes);
|
|
719
|
+
// derivationPrefix
|
|
720
|
+
const derivationPrefixLength = paramsReader.readVarIntNum();
|
|
721
|
+
const derivationPrefixBytes = paramsReader.read(derivationPrefixLength);
|
|
722
|
+
output.paymentRemittance.derivationPrefix = index_1.Utils.toBase64(derivationPrefixBytes);
|
|
723
|
+
// derivationSuffix
|
|
724
|
+
const derivationSuffixLength = paramsReader.readVarIntNum();
|
|
725
|
+
const derivationSuffixBytes = paramsReader.read(derivationSuffixLength);
|
|
726
|
+
output.paymentRemittance.derivationSuffix = index_1.Utils.toBase64(derivationSuffixBytes);
|
|
727
|
+
}
|
|
728
|
+
else if (protocolFlag === 2) {
|
|
729
|
+
output.protocol = "basket insertion";
|
|
730
|
+
output.insertionRemittance = {};
|
|
731
|
+
// basket
|
|
732
|
+
const basketLength = paramsReader.readVarIntNum();
|
|
733
|
+
const basketBytes = paramsReader.read(basketLength);
|
|
734
|
+
output.insertionRemittance.basket = index_1.Utils.toUTF8(basketBytes);
|
|
735
|
+
// customInstructions
|
|
736
|
+
const customInstructionsLength = paramsReader.readVarIntNum();
|
|
737
|
+
if (customInstructionsLength >= 0) {
|
|
738
|
+
const customInstructionsBytes = paramsReader.read(customInstructionsLength);
|
|
739
|
+
output.insertionRemittance.customInstructions = index_1.Utils.toUTF8(customInstructionsBytes);
|
|
740
|
+
}
|
|
741
|
+
// tags
|
|
742
|
+
const tagsLength = paramsReader.readVarIntNum();
|
|
743
|
+
if (tagsLength > 0) {
|
|
744
|
+
output.insertionRemittance.tags = [];
|
|
745
|
+
for (let j = 0; j < tagsLength; j++) {
|
|
746
|
+
const tagLength = paramsReader.readVarIntNum();
|
|
747
|
+
const tagBytes = paramsReader.read(tagLength);
|
|
748
|
+
output.insertionRemittance.tags.push(index_1.Utils.toUTF8(tagBytes));
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
output.insertionRemittance.tags = [];
|
|
753
|
+
}
|
|
819
754
|
}
|
|
820
|
-
|
|
821
|
-
|
|
755
|
+
args.outputs.push(output);
|
|
756
|
+
}
|
|
757
|
+
const numberOfLabels = paramsReader.readVarIntNum();
|
|
758
|
+
if (numberOfLabels >= 0) {
|
|
759
|
+
args.labels = [];
|
|
760
|
+
for (let i = 0; i < numberOfLabels; i++) {
|
|
761
|
+
const labelLength = paramsReader.readVarIntNum();
|
|
762
|
+
args.labels.push(index_1.Utils.toUTF8(paramsReader.read(labelLength)));
|
|
822
763
|
}
|
|
823
|
-
|
|
824
|
-
|
|
764
|
+
}
|
|
765
|
+
const descriptionLength = paramsReader.readVarIntNum();
|
|
766
|
+
args.description = index_1.Utils.toUTF8(paramsReader.read(descriptionLength));
|
|
767
|
+
// Deserialize seekPermission
|
|
768
|
+
const seekPermission = paramsReader.readInt8();
|
|
769
|
+
if (seekPermission >= 0) {
|
|
770
|
+
args.seekPermission = seekPermission === 1;
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
args.seekPermission = undefined;
|
|
774
|
+
}
|
|
775
|
+
// Call the method
|
|
776
|
+
await this.wallet.internalizeAction(args, originator);
|
|
777
|
+
// Return success code and result
|
|
778
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
779
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
780
|
+
return responseWriter.toArray();
|
|
781
|
+
}
|
|
782
|
+
case "listOutputs": {
|
|
783
|
+
const args = {};
|
|
784
|
+
// Deserialize basket
|
|
785
|
+
const basketLength = paramsReader.readVarIntNum();
|
|
786
|
+
const basketBytes = paramsReader.read(basketLength);
|
|
787
|
+
args.basket = index_1.Utils.toUTF8(basketBytes);
|
|
788
|
+
// Deserialize tags
|
|
789
|
+
const tagsLength = paramsReader.readVarIntNum();
|
|
790
|
+
if (tagsLength > 0) {
|
|
791
|
+
args.tags = [];
|
|
792
|
+
for (let i = 0; i < tagsLength; i++) {
|
|
793
|
+
const tagLength = paramsReader.readVarIntNum();
|
|
794
|
+
const tagBytes = paramsReader.read(tagLength);
|
|
795
|
+
args.tags.push(index_1.Utils.toUTF8(tagBytes));
|
|
825
796
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
args.tags = undefined;
|
|
800
|
+
}
|
|
801
|
+
// Deserialize tagQueryMode
|
|
802
|
+
const tagQueryModeFlag = paramsReader.readInt8();
|
|
803
|
+
if (tagQueryModeFlag === 1) {
|
|
804
|
+
args.tagQueryMode = "all";
|
|
805
|
+
}
|
|
806
|
+
else if (tagQueryModeFlag === 2) {
|
|
807
|
+
args.tagQueryMode = "any";
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
args.tagQueryMode = undefined;
|
|
811
|
+
}
|
|
812
|
+
// Deserialize include
|
|
813
|
+
const includeFlag = paramsReader.readInt8();
|
|
814
|
+
if (includeFlag === 1) {
|
|
815
|
+
args.include = "locking scripts";
|
|
816
|
+
}
|
|
817
|
+
else if (includeFlag === 2) {
|
|
818
|
+
args.include = "entire transactions";
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
args.include = undefined;
|
|
822
|
+
}
|
|
823
|
+
// Deserialize includeCustomInstructions
|
|
824
|
+
const includeCustomInstructionsFlag = paramsReader.readInt8();
|
|
825
|
+
if (includeCustomInstructionsFlag === -1) {
|
|
826
|
+
args.includeCustomInstructions = undefined;
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
args.includeCustomInstructions =
|
|
830
|
+
includeCustomInstructionsFlag === 1;
|
|
831
|
+
}
|
|
832
|
+
// Deserialize includeTags
|
|
833
|
+
const includeTagsFlag = paramsReader.readInt8();
|
|
834
|
+
if (includeTagsFlag === -1) {
|
|
835
|
+
args.includeTags = undefined;
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
args.includeTags = includeTagsFlag === 1;
|
|
839
|
+
}
|
|
840
|
+
// Deserialize includeLabels
|
|
841
|
+
const includeLabelsFlag = paramsReader.readInt8();
|
|
842
|
+
if (includeLabelsFlag === -1) {
|
|
843
|
+
args.includeLabels = undefined;
|
|
844
|
+
}
|
|
845
|
+
else {
|
|
846
|
+
args.includeLabels = includeLabelsFlag === 1;
|
|
847
|
+
}
|
|
848
|
+
// Deserialize limit
|
|
849
|
+
const limit = paramsReader.readVarIntNum();
|
|
850
|
+
if (limit >= 0) {
|
|
851
|
+
args.limit = limit;
|
|
852
|
+
}
|
|
853
|
+
else {
|
|
854
|
+
args.limit = undefined;
|
|
855
|
+
}
|
|
856
|
+
// Deserialize offset
|
|
857
|
+
const offset = paramsReader.readVarIntNum();
|
|
858
|
+
if (offset >= 0) {
|
|
859
|
+
args.offset = offset;
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
args.offset = undefined;
|
|
863
|
+
}
|
|
864
|
+
// Deserialize seekPermission
|
|
865
|
+
const seekPermission = paramsReader.readInt8();
|
|
866
|
+
if (seekPermission >= 0) {
|
|
867
|
+
args.seekPermission = seekPermission === 1;
|
|
868
|
+
}
|
|
869
|
+
else {
|
|
870
|
+
args.seekPermission = undefined;
|
|
871
|
+
}
|
|
872
|
+
// Call the method
|
|
873
|
+
const listOutputsResult = await this.wallet.listOutputs(args, originator);
|
|
874
|
+
// Serialize the result
|
|
875
|
+
const resultWriter = new index_1.Utils.Writer();
|
|
876
|
+
// totalOutputs
|
|
877
|
+
resultWriter.writeVarIntNum(listOutputsResult.totalOutputs);
|
|
878
|
+
// BEEF length and BEEF or -1
|
|
879
|
+
if (listOutputsResult.BEEF) {
|
|
880
|
+
resultWriter.writeVarIntNum(listOutputsResult.BEEF.length);
|
|
881
|
+
resultWriter.write(listOutputsResult.BEEF);
|
|
882
|
+
}
|
|
883
|
+
else {
|
|
884
|
+
resultWriter.writeVarIntNum(-1);
|
|
885
|
+
}
|
|
886
|
+
// outputs
|
|
887
|
+
for (const output of listOutputsResult.outputs) {
|
|
888
|
+
// outpoint
|
|
889
|
+
resultWriter.write(this.encodeOutpoint(output.outpoint));
|
|
890
|
+
// satoshis
|
|
891
|
+
resultWriter.writeVarIntNum(output.satoshis);
|
|
892
|
+
// lockingScript
|
|
893
|
+
if (output.lockingScript !== undefined) {
|
|
894
|
+
const lockingScriptBytes = index_1.Utils.toArray(output.lockingScript, "hex");
|
|
895
|
+
resultWriter.writeVarIntNum(lockingScriptBytes.length);
|
|
896
|
+
resultWriter.write(lockingScriptBytes);
|
|
830
897
|
}
|
|
831
898
|
else {
|
|
832
|
-
|
|
899
|
+
resultWriter.writeVarIntNum(-1);
|
|
833
900
|
}
|
|
834
|
-
//
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
901
|
+
// customInstructions
|
|
902
|
+
if (output.customInstructions !== undefined) {
|
|
903
|
+
const customInstructionsBytes = index_1.Utils.toArray(output.customInstructions, "utf8");
|
|
904
|
+
resultWriter.writeVarIntNum(customInstructionsBytes.length);
|
|
905
|
+
resultWriter.write(customInstructionsBytes);
|
|
838
906
|
}
|
|
839
907
|
else {
|
|
840
|
-
|
|
908
|
+
resultWriter.writeVarIntNum(-1);
|
|
841
909
|
}
|
|
842
|
-
//
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
910
|
+
// tags
|
|
911
|
+
if (output.tags !== undefined) {
|
|
912
|
+
resultWriter.writeVarIntNum(output.tags.length);
|
|
913
|
+
for (const tag of output.tags) {
|
|
914
|
+
const tagBytes = index_1.Utils.toArray(tag, "utf8");
|
|
915
|
+
resultWriter.writeVarIntNum(tagBytes.length);
|
|
916
|
+
resultWriter.write(tagBytes);
|
|
917
|
+
}
|
|
846
918
|
}
|
|
847
919
|
else {
|
|
848
|
-
|
|
920
|
+
resultWriter.writeVarIntNum(-1);
|
|
849
921
|
}
|
|
850
|
-
//
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
922
|
+
// labels
|
|
923
|
+
if (output.labels !== undefined) {
|
|
924
|
+
resultWriter.writeVarIntNum(output.labels.length);
|
|
925
|
+
for (const label of output.labels) {
|
|
926
|
+
const labelBytes = index_1.Utils.toArray(label, "utf8");
|
|
927
|
+
resultWriter.writeVarIntNum(labelBytes.length);
|
|
928
|
+
resultWriter.write(labelBytes);
|
|
929
|
+
}
|
|
854
930
|
}
|
|
855
931
|
else {
|
|
856
|
-
|
|
932
|
+
resultWriter.writeVarIntNum(-1);
|
|
857
933
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
//
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
resultWriter.writeVarIntNum(output.satoshis);
|
|
894
|
-
// lockingScript
|
|
895
|
-
if (output.lockingScript !== undefined) {
|
|
896
|
-
const lockingScriptBytes = index_js_1.Utils.toArray(output.lockingScript, 'hex');
|
|
897
|
-
resultWriter.writeVarIntNum(lockingScriptBytes.length);
|
|
898
|
-
resultWriter.write(lockingScriptBytes);
|
|
899
|
-
}
|
|
900
|
-
else {
|
|
901
|
-
resultWriter.writeVarIntNum(-1);
|
|
902
|
-
}
|
|
903
|
-
// customInstructions
|
|
904
|
-
if (output.customInstructions !== undefined) {
|
|
905
|
-
const customInstructionsBytes = index_js_1.Utils.toArray(output.customInstructions, 'utf8');
|
|
906
|
-
resultWriter.writeVarIntNum(customInstructionsBytes.length);
|
|
907
|
-
resultWriter.write(customInstructionsBytes);
|
|
908
|
-
}
|
|
909
|
-
else {
|
|
910
|
-
resultWriter.writeVarIntNum(-1);
|
|
911
|
-
}
|
|
912
|
-
// tags
|
|
913
|
-
if (output.tags !== undefined) {
|
|
914
|
-
resultWriter.writeVarIntNum(output.tags.length);
|
|
915
|
-
for (const tag of output.tags) {
|
|
916
|
-
const tagBytes = index_js_1.Utils.toArray(tag, 'utf8');
|
|
917
|
-
resultWriter.writeVarIntNum(tagBytes.length);
|
|
918
|
-
resultWriter.write(tagBytes);
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
else {
|
|
922
|
-
resultWriter.writeVarIntNum(-1);
|
|
923
|
-
}
|
|
924
|
-
// labels
|
|
925
|
-
if (output.labels !== undefined) {
|
|
926
|
-
resultWriter.writeVarIntNum(output.labels.length);
|
|
927
|
-
for (const label of output.labels) {
|
|
928
|
-
const labelBytes = index_js_1.Utils.toArray(label, 'utf8');
|
|
929
|
-
resultWriter.writeVarIntNum(labelBytes.length);
|
|
930
|
-
resultWriter.write(labelBytes);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
else {
|
|
934
|
-
resultWriter.writeVarIntNum(-1);
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
// Return success code and result
|
|
938
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
939
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
940
|
-
responseWriter.write(resultWriter.toArray());
|
|
941
|
-
return responseWriter.toArray();
|
|
942
|
-
}
|
|
943
|
-
case 'relinquishOutput':
|
|
944
|
-
{
|
|
945
|
-
const args = {};
|
|
946
|
-
// Deserialize basket
|
|
947
|
-
const basketLength = paramsReader.readVarIntNum();
|
|
948
|
-
const basketBytes = paramsReader.read(basketLength);
|
|
949
|
-
args.basket = index_js_1.Utils.toUTF8(basketBytes);
|
|
950
|
-
// Deserialize outpoint
|
|
951
|
-
args.output = this.decodeOutpoint(paramsReader);
|
|
952
|
-
// Call the method
|
|
953
|
-
await this.wallet.relinquishOutput(args, originator);
|
|
954
|
-
// Return success code and result
|
|
955
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
956
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
957
|
-
return responseWriter.toArray();
|
|
958
|
-
}
|
|
959
|
-
case 'getPublicKey':
|
|
960
|
-
{
|
|
961
|
-
const args = {};
|
|
962
|
-
// Deserialize identityKey flag
|
|
963
|
-
const identityKeyFlag = paramsReader.readUInt8();
|
|
964
|
-
args.identityKey = identityKeyFlag === 1;
|
|
965
|
-
if (!args.identityKey) {
|
|
966
|
-
// Deserialize protocolID
|
|
967
|
-
args.protocolID = this.decodeProtocolID(paramsReader);
|
|
968
|
-
// Deserialize keyID
|
|
969
|
-
args.keyID = this.decodeString(paramsReader);
|
|
970
|
-
// Deserialize counterparty
|
|
971
|
-
args.counterparty = this.decodeCounterparty(paramsReader);
|
|
972
|
-
// Deserialize privilege parameters
|
|
973
|
-
const privilegedFlag = paramsReader.readInt8();
|
|
974
|
-
if (privilegedFlag === -1) {
|
|
975
|
-
args.privileged = undefined;
|
|
976
|
-
}
|
|
977
|
-
else {
|
|
978
|
-
args.privileged = privilegedFlag === 1;
|
|
979
|
-
}
|
|
980
|
-
const privilegedReasonLength = paramsReader.readInt8();
|
|
981
|
-
if (privilegedReasonLength !== -1) {
|
|
982
|
-
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
983
|
-
args.privilegedReason = index_js_1.Utils.toUTF8(privilegedReasonBytes);
|
|
984
|
-
}
|
|
985
|
-
else {
|
|
986
|
-
args.privilegedReason = undefined;
|
|
987
|
-
}
|
|
988
|
-
// Deserialize forSelf
|
|
989
|
-
const forSelfFlag = paramsReader.readInt8();
|
|
990
|
-
if (forSelfFlag === -1) {
|
|
991
|
-
args.forSelf = undefined;
|
|
992
|
-
}
|
|
993
|
-
else {
|
|
994
|
-
args.forSelf = forSelfFlag === 1;
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
else {
|
|
998
|
-
// Deserialize privilege parameters
|
|
999
|
-
const privilegedFlag = paramsReader.readInt8();
|
|
1000
|
-
if (privilegedFlag === -1) {
|
|
1001
|
-
args.privileged = undefined;
|
|
1002
|
-
}
|
|
1003
|
-
else {
|
|
1004
|
-
args.privileged = privilegedFlag === 1;
|
|
1005
|
-
}
|
|
1006
|
-
const privilegedReasonLength = paramsReader.readInt8();
|
|
1007
|
-
if (privilegedReasonLength !== -1) {
|
|
1008
|
-
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1009
|
-
args.privilegedReason = index_js_1.Utils.toUTF8(privilegedReasonBytes);
|
|
1010
|
-
}
|
|
1011
|
-
else {
|
|
1012
|
-
args.privilegedReason = undefined;
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
// Deserialize seekPermission
|
|
1016
|
-
const seekPermission = paramsReader.readInt8();
|
|
1017
|
-
if (seekPermission >= 0) {
|
|
1018
|
-
args.seekPermission = seekPermission === 1;
|
|
1019
|
-
}
|
|
1020
|
-
else {
|
|
1021
|
-
args.seekPermission = undefined;
|
|
1022
|
-
}
|
|
1023
|
-
// Call the method
|
|
1024
|
-
const getPublicKeyResult = await this.wallet.getPublicKey(args, originator);
|
|
1025
|
-
// Serialize the result
|
|
1026
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1027
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1028
|
-
const publicKeyBytes = index_js_1.Utils.toArray(getPublicKeyResult.publicKey, 'hex');
|
|
1029
|
-
responseWriter.write(publicKeyBytes);
|
|
1030
|
-
return responseWriter.toArray();
|
|
1031
|
-
}
|
|
1032
|
-
case 'encrypt':
|
|
1033
|
-
{
|
|
1034
|
-
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1035
|
-
// Deserialize plaintext
|
|
1036
|
-
const plaintextLength = paramsReader.readVarIntNum();
|
|
1037
|
-
args.plaintext = paramsReader.read(plaintextLength);
|
|
1038
|
-
// Deserialize seekPermission
|
|
1039
|
-
const seekPermission = paramsReader.readInt8();
|
|
1040
|
-
if (seekPermission >= 0) {
|
|
1041
|
-
args.seekPermission = seekPermission === 1;
|
|
1042
|
-
}
|
|
1043
|
-
else {
|
|
1044
|
-
args.seekPermission = undefined;
|
|
1045
|
-
}
|
|
1046
|
-
// Call the method
|
|
1047
|
-
const encryptResult = await this.wallet.encrypt(args, originator);
|
|
1048
|
-
// Serialize the result
|
|
1049
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1050
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1051
|
-
responseWriter.write(encryptResult.ciphertext);
|
|
1052
|
-
return responseWriter.toArray();
|
|
1053
|
-
}
|
|
1054
|
-
case 'decrypt':
|
|
1055
|
-
{
|
|
1056
|
-
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1057
|
-
// Deserialize ciphertext
|
|
1058
|
-
const ciphertextLength = paramsReader.readVarIntNum();
|
|
1059
|
-
args.ciphertext = paramsReader.read(ciphertextLength);
|
|
1060
|
-
// Deserialize seekPermission
|
|
1061
|
-
const seekPermission = paramsReader.readInt8();
|
|
1062
|
-
if (seekPermission >= 0) {
|
|
1063
|
-
args.seekPermission = seekPermission === 1;
|
|
1064
|
-
}
|
|
1065
|
-
else {
|
|
1066
|
-
args.seekPermission = undefined;
|
|
1067
|
-
}
|
|
1068
|
-
// Call the method
|
|
1069
|
-
const decryptResult = await this.wallet.decrypt(args, originator);
|
|
1070
|
-
// Serialize the result
|
|
1071
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1072
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1073
|
-
responseWriter.write(decryptResult.plaintext);
|
|
1074
|
-
return responseWriter.toArray();
|
|
1075
|
-
}
|
|
1076
|
-
case 'createHmac':
|
|
1077
|
-
{
|
|
1078
|
-
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1079
|
-
// Deserialize data
|
|
1080
|
-
const dataLength = paramsReader.readVarIntNum();
|
|
1081
|
-
args.data = paramsReader.read(dataLength);
|
|
1082
|
-
// Deserialize seekPermission
|
|
1083
|
-
const seekPermission = paramsReader.readInt8();
|
|
1084
|
-
if (seekPermission >= 0) {
|
|
1085
|
-
args.seekPermission = seekPermission === 1;
|
|
1086
|
-
}
|
|
1087
|
-
else {
|
|
1088
|
-
args.seekPermission = undefined;
|
|
1089
|
-
}
|
|
1090
|
-
// Call the method
|
|
1091
|
-
const createHmacResult = await this.wallet.createHmac(args, originator);
|
|
1092
|
-
// Serialize the result
|
|
1093
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1094
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1095
|
-
responseWriter.write(createHmacResult.hmac);
|
|
1096
|
-
return responseWriter.toArray();
|
|
1097
|
-
}
|
|
1098
|
-
case 'verifyHmac':
|
|
1099
|
-
{
|
|
1100
|
-
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1101
|
-
// Deserialize hmac
|
|
1102
|
-
args.hmac = paramsReader.read(32);
|
|
1103
|
-
// Deserialize data
|
|
1104
|
-
const dataLength = paramsReader.readVarIntNum();
|
|
1105
|
-
args.data = paramsReader.read(dataLength);
|
|
1106
|
-
// Deserialize seekPermission
|
|
1107
|
-
const seekPermission = paramsReader.readInt8();
|
|
1108
|
-
if (seekPermission >= 0) {
|
|
1109
|
-
args.seekPermission = seekPermission === 1;
|
|
1110
|
-
}
|
|
1111
|
-
else {
|
|
1112
|
-
args.seekPermission = undefined;
|
|
1113
|
-
}
|
|
1114
|
-
// Call the method
|
|
1115
|
-
await this.wallet.verifyHmac(args, originator);
|
|
1116
|
-
// Serialize the result (no data to return)
|
|
1117
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1118
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1119
|
-
return responseWriter.toArray();
|
|
1120
|
-
}
|
|
1121
|
-
case 'createSignature':
|
|
1122
|
-
{
|
|
1123
|
-
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1124
|
-
// Deserialize data or hashToDirectlySign
|
|
1125
|
-
const dataTypeFlag = paramsReader.readUInt8();
|
|
1126
|
-
if (dataTypeFlag === 1) {
|
|
1127
|
-
const dataLength = paramsReader.readVarIntNum();
|
|
1128
|
-
args.data = paramsReader.read(dataLength);
|
|
1129
|
-
}
|
|
1130
|
-
else if (dataTypeFlag === 2) {
|
|
1131
|
-
args.hashToDirectlySign = paramsReader.read(32);
|
|
1132
|
-
}
|
|
1133
|
-
// Deserialize seekPermission
|
|
1134
|
-
const seekPermission = paramsReader.readInt8();
|
|
1135
|
-
if (seekPermission >= 0) {
|
|
1136
|
-
args.seekPermission = seekPermission === 1;
|
|
1137
|
-
}
|
|
1138
|
-
else {
|
|
1139
|
-
args.seekPermission = undefined;
|
|
1140
|
-
}
|
|
1141
|
-
// Call the method
|
|
1142
|
-
const createSignatureResult = await this.wallet.createSignature(args, originator);
|
|
1143
|
-
// Serialize the result
|
|
1144
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1145
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1146
|
-
responseWriter.write(createSignatureResult.signature);
|
|
1147
|
-
return responseWriter.toArray();
|
|
1148
|
-
}
|
|
1149
|
-
case 'verifySignature':
|
|
1150
|
-
{
|
|
1151
|
-
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1152
|
-
// Deserialize forSelf
|
|
1153
|
-
const forSelfFlag = paramsReader.readInt8();
|
|
1154
|
-
if (forSelfFlag === -1) {
|
|
1155
|
-
args.forSelf = undefined;
|
|
1156
|
-
}
|
|
1157
|
-
else {
|
|
1158
|
-
args.forSelf = forSelfFlag === 1;
|
|
1159
|
-
}
|
|
1160
|
-
// Deserialize signature
|
|
1161
|
-
const signatureLength = paramsReader.readVarIntNum();
|
|
1162
|
-
args.signature = paramsReader.read(signatureLength);
|
|
1163
|
-
// Deserialize data or hashToDirectlyVerify
|
|
1164
|
-
const dataTypeFlag = paramsReader.readUInt8();
|
|
1165
|
-
if (dataTypeFlag === 1) {
|
|
1166
|
-
const dataLength = paramsReader.readVarIntNum();
|
|
1167
|
-
args.data = paramsReader.read(dataLength);
|
|
1168
|
-
}
|
|
1169
|
-
else if (dataTypeFlag === 2) {
|
|
1170
|
-
args.hashToDirectlyVerify = paramsReader.read(32);
|
|
1171
|
-
}
|
|
1172
|
-
// Deserialize seekPermission
|
|
1173
|
-
const seekPermission = paramsReader.readInt8();
|
|
1174
|
-
if (seekPermission >= 0) {
|
|
1175
|
-
args.seekPermission = seekPermission === 1;
|
|
1176
|
-
}
|
|
1177
|
-
else {
|
|
1178
|
-
args.seekPermission = undefined;
|
|
1179
|
-
}
|
|
1180
|
-
// Call the method
|
|
1181
|
-
await this.wallet.verifySignature(args, originator);
|
|
1182
|
-
// Serialize the result (no data to return)
|
|
1183
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1184
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1185
|
-
return responseWriter.toArray();
|
|
1186
|
-
}
|
|
1187
|
-
case 'isAuthenticated':
|
|
1188
|
-
{
|
|
1189
|
-
// No parameters to deserialize
|
|
1190
|
-
// Call the method
|
|
1191
|
-
const isAuthenticatedResult = await this.wallet.isAuthenticated({}, originator);
|
|
1192
|
-
// Serialize the result
|
|
1193
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1194
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1195
|
-
responseWriter.writeUInt8(isAuthenticatedResult.authenticated ? 1 : 0);
|
|
1196
|
-
return responseWriter.toArray();
|
|
1197
|
-
}
|
|
1198
|
-
case 'waitForAuthentication':
|
|
1199
|
-
{
|
|
1200
|
-
// No parameters to deserialize
|
|
1201
|
-
// Call the method
|
|
1202
|
-
await this.wallet.waitForAuthentication({}, originator);
|
|
1203
|
-
// Serialize the result (authenticated is always true)
|
|
1204
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1205
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1206
|
-
return responseWriter.toArray();
|
|
1207
|
-
}
|
|
1208
|
-
case 'getHeight':
|
|
1209
|
-
{
|
|
1210
|
-
// No parameters to deserialize
|
|
1211
|
-
// Call the method
|
|
1212
|
-
const getHeightResult = await this.wallet.getHeight({}, originator);
|
|
1213
|
-
// Serialize the result
|
|
1214
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1215
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1216
|
-
responseWriter.writeVarIntNum(getHeightResult.height);
|
|
1217
|
-
return responseWriter.toArray();
|
|
1218
|
-
}
|
|
1219
|
-
case 'getHeaderForHeight':
|
|
1220
|
-
{
|
|
1221
|
-
const args = {};
|
|
1222
|
-
// Deserialize height
|
|
1223
|
-
args.height = paramsReader.readVarIntNum();
|
|
1224
|
-
// Call the method
|
|
1225
|
-
const getHeaderResult = await this.wallet.getHeaderForHeight(args, originator);
|
|
1226
|
-
// Serialize the result
|
|
1227
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1228
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1229
|
-
const headerBytes = index_js_1.Utils.toArray(getHeaderResult.header, 'hex');
|
|
1230
|
-
responseWriter.write(headerBytes);
|
|
1231
|
-
return responseWriter.toArray();
|
|
1232
|
-
}
|
|
1233
|
-
case 'getNetwork':
|
|
1234
|
-
{
|
|
1235
|
-
// No parameters to deserialize
|
|
1236
|
-
// Call the method
|
|
1237
|
-
const getNetworkResult = await this.wallet.getNetwork({}, originator);
|
|
1238
|
-
// Serialize the result
|
|
1239
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1240
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1241
|
-
responseWriter.writeUInt8(getNetworkResult.network === 'mainnet' ? 0 : 1);
|
|
1242
|
-
return responseWriter.toArray();
|
|
1243
|
-
}
|
|
1244
|
-
case 'getVersion':
|
|
1245
|
-
{
|
|
1246
|
-
// No parameters to deserialize
|
|
1247
|
-
// Call the method
|
|
1248
|
-
const getVersionResult = await this.wallet.getVersion({}, originator);
|
|
1249
|
-
// Serialize the result
|
|
1250
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1251
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1252
|
-
const versionBytes = index_js_1.Utils.toArray(getVersionResult.version, 'utf8');
|
|
1253
|
-
responseWriter.write(versionBytes);
|
|
1254
|
-
return responseWriter.toArray();
|
|
1255
|
-
}
|
|
1256
|
-
case 'revealCounterpartyKeyLinkage':
|
|
1257
|
-
{
|
|
1258
|
-
const args = {};
|
|
1259
|
-
// Read privileged parameters
|
|
934
|
+
}
|
|
935
|
+
// Return success code and result
|
|
936
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
937
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
938
|
+
responseWriter.write(resultWriter.toArray());
|
|
939
|
+
return responseWriter.toArray();
|
|
940
|
+
}
|
|
941
|
+
case "relinquishOutput": {
|
|
942
|
+
const args = {};
|
|
943
|
+
// Deserialize basket
|
|
944
|
+
const basketLength = paramsReader.readVarIntNum();
|
|
945
|
+
const basketBytes = paramsReader.read(basketLength);
|
|
946
|
+
args.basket = index_1.Utils.toUTF8(basketBytes);
|
|
947
|
+
// Deserialize outpoint
|
|
948
|
+
args.output = this.decodeOutpoint(paramsReader);
|
|
949
|
+
// Call the method
|
|
950
|
+
await this.wallet.relinquishOutput(args, originator);
|
|
951
|
+
// Return success code and result
|
|
952
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
953
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
954
|
+
return responseWriter.toArray();
|
|
955
|
+
}
|
|
956
|
+
case "getPublicKey": {
|
|
957
|
+
const args = {};
|
|
958
|
+
// Deserialize identityKey flag
|
|
959
|
+
const identityKeyFlag = paramsReader.readUInt8();
|
|
960
|
+
args.identityKey = identityKeyFlag === 1;
|
|
961
|
+
if (!args.identityKey) {
|
|
962
|
+
// Deserialize protocolID
|
|
963
|
+
args.protocolID = this.decodeProtocolID(paramsReader);
|
|
964
|
+
// Deserialize keyID
|
|
965
|
+
args.keyID = this.decodeString(paramsReader);
|
|
966
|
+
// Deserialize counterparty
|
|
967
|
+
args.counterparty = this.decodeCounterparty(paramsReader);
|
|
968
|
+
// Deserialize privilege parameters
|
|
1260
969
|
const privilegedFlag = paramsReader.readInt8();
|
|
1261
970
|
if (privilegedFlag === -1) {
|
|
1262
971
|
args.privileged = undefined;
|
|
@@ -1265,208 +974,24 @@ class WalletWireProcessor {
|
|
|
1265
974
|
args.privileged = privilegedFlag === 1;
|
|
1266
975
|
}
|
|
1267
976
|
const privilegedReasonLength = paramsReader.readInt8();
|
|
1268
|
-
if (privilegedReasonLength
|
|
1269
|
-
args.privilegedReason = undefined;
|
|
1270
|
-
}
|
|
1271
|
-
else {
|
|
977
|
+
if (privilegedReasonLength !== -1) {
|
|
1272
978
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1273
|
-
args.privilegedReason =
|
|
1274
|
-
}
|
|
1275
|
-
// Read counterparty public key
|
|
1276
|
-
const counterpartyBytes = paramsReader.read(33);
|
|
1277
|
-
args.counterparty = index_js_1.Utils.toHex(counterpartyBytes);
|
|
1278
|
-
// Read verifier public key
|
|
1279
|
-
const verifierBytes = paramsReader.read(33);
|
|
1280
|
-
args.verifier = index_js_1.Utils.toHex(verifierBytes);
|
|
1281
|
-
// Call the method
|
|
1282
|
-
const revealResult = await this.wallet.revealCounterpartyKeyLinkage(args, originator);
|
|
1283
|
-
// Serialize the result
|
|
1284
|
-
const resultWriter = new index_js_1.Utils.Writer();
|
|
1285
|
-
// Write prover
|
|
1286
|
-
resultWriter.write(index_js_1.Utils.toArray(revealResult.prover, 'hex'));
|
|
1287
|
-
// Write verifier
|
|
1288
|
-
resultWriter.write(index_js_1.Utils.toArray(revealResult.verifier, 'hex'));
|
|
1289
|
-
// Write counterparty
|
|
1290
|
-
resultWriter.write(index_js_1.Utils.toArray(revealResult.counterparty, 'hex'));
|
|
1291
|
-
// Write revelationTime
|
|
1292
|
-
const revelationTimeBytes = index_js_1.Utils.toArray(revealResult.revelationTime, 'utf8');
|
|
1293
|
-
resultWriter.writeVarIntNum(revelationTimeBytes.length);
|
|
1294
|
-
resultWriter.write(revelationTimeBytes);
|
|
1295
|
-
// Write encryptedLinkage
|
|
1296
|
-
resultWriter.writeVarIntNum(revealResult.encryptedLinkage.length);
|
|
1297
|
-
resultWriter.write(revealResult.encryptedLinkage);
|
|
1298
|
-
// Write encryptedLinkageProof
|
|
1299
|
-
resultWriter.writeVarIntNum(revealResult.encryptedLinkageProof.length);
|
|
1300
|
-
resultWriter.write(revealResult.encryptedLinkageProof);
|
|
1301
|
-
// Return success code and result
|
|
1302
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1303
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1304
|
-
responseWriter.write(resultWriter.toArray());
|
|
1305
|
-
return responseWriter.toArray();
|
|
1306
|
-
}
|
|
1307
|
-
case 'revealSpecificKeyLinkage':
|
|
1308
|
-
{
|
|
1309
|
-
// Deserialize key-related parameters and privileged parameters
|
|
1310
|
-
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1311
|
-
// Read verifier public key
|
|
1312
|
-
const verifierBytes = paramsReader.read(33);
|
|
1313
|
-
args.verifier = index_js_1.Utils.toHex(verifierBytes);
|
|
1314
|
-
// Call the method
|
|
1315
|
-
const revealResult = await this.wallet.revealSpecificKeyLinkage(args, originator);
|
|
1316
|
-
// Serialize the result
|
|
1317
|
-
const resultWriter = new index_js_1.Utils.Writer();
|
|
1318
|
-
// Write prover
|
|
1319
|
-
resultWriter.write(index_js_1.Utils.toArray(revealResult.prover, 'hex'));
|
|
1320
|
-
// Write verifier
|
|
1321
|
-
resultWriter.write(index_js_1.Utils.toArray(revealResult.verifier, 'hex'));
|
|
1322
|
-
// Write counterparty
|
|
1323
|
-
resultWriter.write(index_js_1.Utils.toArray(revealResult.counterparty, 'hex'));
|
|
1324
|
-
// Write securityLevel
|
|
1325
|
-
resultWriter.writeUInt8(revealResult.protocolID[0]);
|
|
1326
|
-
// Write protocol string
|
|
1327
|
-
const protocolBytesOut = index_js_1.Utils.toArray(revealResult.protocolID[1], 'utf8');
|
|
1328
|
-
resultWriter.writeVarIntNum(protocolBytesOut.length);
|
|
1329
|
-
resultWriter.write(protocolBytesOut);
|
|
1330
|
-
// Write keyID
|
|
1331
|
-
const keyIDBytesOut = index_js_1.Utils.toArray(revealResult.keyID, 'utf8');
|
|
1332
|
-
resultWriter.writeVarIntNum(keyIDBytesOut.length);
|
|
1333
|
-
resultWriter.write(keyIDBytesOut);
|
|
1334
|
-
// Write encryptedLinkage
|
|
1335
|
-
resultWriter.writeVarIntNum(revealResult.encryptedLinkage.length);
|
|
1336
|
-
resultWriter.write(revealResult.encryptedLinkage);
|
|
1337
|
-
// Write encryptedLinkageProof
|
|
1338
|
-
resultWriter.writeVarIntNum(revealResult.encryptedLinkageProof.length);
|
|
1339
|
-
resultWriter.write(revealResult.encryptedLinkageProof);
|
|
1340
|
-
// Write proofType
|
|
1341
|
-
resultWriter.writeUInt8(revealResult.proofType);
|
|
1342
|
-
// Return success code and result
|
|
1343
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1344
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1345
|
-
responseWriter.write(resultWriter.toArray());
|
|
1346
|
-
return responseWriter.toArray();
|
|
1347
|
-
}
|
|
1348
|
-
case 'acquireCertificate':
|
|
1349
|
-
{
|
|
1350
|
-
const args = {};
|
|
1351
|
-
// Read args.type
|
|
1352
|
-
const typeBytes = paramsReader.read(32);
|
|
1353
|
-
args.type = index_js_1.Utils.toBase64(typeBytes);
|
|
1354
|
-
// args.certifier
|
|
1355
|
-
const certifierBytes = paramsReader.read(33);
|
|
1356
|
-
args.certifier = index_js_1.Utils.toHex(certifierBytes);
|
|
1357
|
-
// Read fields
|
|
1358
|
-
const fieldsLength = paramsReader.readVarIntNum();
|
|
1359
|
-
args.fields = {};
|
|
1360
|
-
for (let i = 0; i < fieldsLength; i++) {
|
|
1361
|
-
const fieldNameLength = paramsReader.readVarIntNum();
|
|
1362
|
-
const fieldNameBytes = paramsReader.read(fieldNameLength);
|
|
1363
|
-
const fieldName = index_js_1.Utils.toUTF8(fieldNameBytes);
|
|
1364
|
-
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1365
|
-
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1366
|
-
const fieldValue = index_js_1.Utils.toUTF8(fieldValueBytes);
|
|
1367
|
-
args.fields[fieldName] = fieldValue;
|
|
1368
|
-
}
|
|
1369
|
-
// Read privileged parameters
|
|
1370
|
-
const privilegedFlag = paramsReader.readInt8();
|
|
1371
|
-
if (privilegedFlag === -1) {
|
|
1372
|
-
args.privileged = undefined;
|
|
979
|
+
args.privilegedReason = index_1.Utils.toUTF8(privilegedReasonBytes);
|
|
1373
980
|
}
|
|
1374
981
|
else {
|
|
1375
|
-
args.privileged = privilegedFlag === 1;
|
|
1376
|
-
}
|
|
1377
|
-
const privilegedReasonLength = paramsReader.readInt8();
|
|
1378
|
-
if (privilegedReasonLength === -1) {
|
|
1379
982
|
args.privilegedReason = undefined;
|
|
1380
983
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
// Read acquisitionProtocol
|
|
1386
|
-
const acquisitionProtocolFlag = paramsReader.readUInt8();
|
|
1387
|
-
args.acquisitionProtocol = acquisitionProtocolFlag === 1 ? 'direct' : 'issuance';
|
|
1388
|
-
if (args.acquisitionProtocol === 'direct') {
|
|
1389
|
-
// args.serialNumber
|
|
1390
|
-
const serialNumberBytes = paramsReader.read(32);
|
|
1391
|
-
args.serialNumber = index_js_1.Utils.toBase64(serialNumberBytes);
|
|
1392
|
-
// args.revocationOutpoint
|
|
1393
|
-
args.revocationOutpoint = this.decodeOutpoint(paramsReader);
|
|
1394
|
-
// args.signature
|
|
1395
|
-
const signatureLength = paramsReader.readVarIntNum();
|
|
1396
|
-
const signatureBytes = paramsReader.read(signatureLength);
|
|
1397
|
-
args.signature = index_js_1.Utils.toHex(signatureBytes);
|
|
1398
|
-
// args.keyringRevealer
|
|
1399
|
-
const keyringRevealerIdentifier = paramsReader.readUInt8();
|
|
1400
|
-
if (keyringRevealerIdentifier === 11) {
|
|
1401
|
-
args.keyringRevealer = 'certifier';
|
|
1402
|
-
}
|
|
1403
|
-
else {
|
|
1404
|
-
const keyringRevealerBytes = [keyringRevealerIdentifier].concat(paramsReader.read(32));
|
|
1405
|
-
args.keyringRevealer = index_js_1.Utils.toHex(keyringRevealerBytes);
|
|
1406
|
-
}
|
|
1407
|
-
// args.keyringForSubject
|
|
1408
|
-
const keyringEntriesLength = paramsReader.readVarIntNum();
|
|
1409
|
-
args.keyringForSubject = {};
|
|
1410
|
-
for (let i = 0; i < keyringEntriesLength; i++) {
|
|
1411
|
-
const fieldKeyLength = paramsReader.readVarIntNum();
|
|
1412
|
-
const fieldKeyBytes = paramsReader.read(fieldKeyLength);
|
|
1413
|
-
const fieldKey = index_js_1.Utils.toUTF8(fieldKeyBytes);
|
|
1414
|
-
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1415
|
-
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1416
|
-
const fieldValue = index_js_1.Utils.toBase64(fieldValueBytes);
|
|
1417
|
-
args.keyringForSubject[fieldKey] = fieldValue;
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
else {
|
|
1421
|
-
// args.certifierUrl
|
|
1422
|
-
const certifierUrlLength = paramsReader.readVarIntNum();
|
|
1423
|
-
const certifierUrlBytes = paramsReader.read(certifierUrlLength);
|
|
1424
|
-
args.certifierUrl = index_js_1.Utils.toUTF8(certifierUrlBytes);
|
|
1425
|
-
}
|
|
1426
|
-
// Call the method
|
|
1427
|
-
const acquireResult = await this.wallet.acquireCertificate(args, originator);
|
|
1428
|
-
// Serialize the certificate (assuming Certificate class is available)
|
|
1429
|
-
const cert = new Certificate_js_1.default(acquireResult.type, acquireResult.serialNumber, acquireResult.subject, acquireResult.certifier, acquireResult.revocationOutpoint, acquireResult.fields, acquireResult.signature);
|
|
1430
|
-
const certBin = cert.toBinary();
|
|
1431
|
-
// Return success code and certificate binary
|
|
1432
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1433
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1434
|
-
responseWriter.write(certBin);
|
|
1435
|
-
return responseWriter.toArray();
|
|
1436
|
-
}
|
|
1437
|
-
case 'listCertificates':
|
|
1438
|
-
{
|
|
1439
|
-
const args = {};
|
|
1440
|
-
// Read certifiers
|
|
1441
|
-
const certifiersLength = paramsReader.readVarIntNum();
|
|
1442
|
-
args.certifiers = [];
|
|
1443
|
-
for (let i = 0; i < certifiersLength; i++) {
|
|
1444
|
-
const certifierBytes = paramsReader.read(33);
|
|
1445
|
-
args.certifiers.push(index_js_1.Utils.toHex(certifierBytes));
|
|
1446
|
-
}
|
|
1447
|
-
// Read types
|
|
1448
|
-
const typesLength = paramsReader.readVarIntNum();
|
|
1449
|
-
args.types = [];
|
|
1450
|
-
for (let i = 0; i < typesLength; i++) {
|
|
1451
|
-
const typeBytes = paramsReader.read(32);
|
|
1452
|
-
args.types.push(index_js_1.Utils.toBase64(typeBytes));
|
|
1453
|
-
}
|
|
1454
|
-
// Read limit and offset
|
|
1455
|
-
const limit = paramsReader.readVarIntNum();
|
|
1456
|
-
if (limit >= 0) {
|
|
1457
|
-
args.limit = limit;
|
|
1458
|
-
}
|
|
1459
|
-
else {
|
|
1460
|
-
args.limit = undefined;
|
|
1461
|
-
}
|
|
1462
|
-
const offset = paramsReader.readVarIntNum();
|
|
1463
|
-
if (offset >= 0) {
|
|
1464
|
-
args.offset = offset;
|
|
984
|
+
// Deserialize forSelf
|
|
985
|
+
const forSelfFlag = paramsReader.readInt8();
|
|
986
|
+
if (forSelfFlag === -1) {
|
|
987
|
+
args.forSelf = undefined;
|
|
1465
988
|
}
|
|
1466
989
|
else {
|
|
1467
|
-
args.
|
|
990
|
+
args.forSelf = forSelfFlag === 1;
|
|
1468
991
|
}
|
|
1469
|
-
|
|
992
|
+
}
|
|
993
|
+
else {
|
|
994
|
+
// Deserialize privilege parameters
|
|
1470
995
|
const privilegedFlag = paramsReader.readInt8();
|
|
1471
996
|
if (privilegedFlag === -1) {
|
|
1472
997
|
args.privileged = undefined;
|
|
@@ -1475,238 +1000,690 @@ class WalletWireProcessor {
|
|
|
1475
1000
|
args.privileged = privilegedFlag === 1;
|
|
1476
1001
|
}
|
|
1477
1002
|
const privilegedReasonLength = paramsReader.readInt8();
|
|
1478
|
-
if (privilegedReasonLength
|
|
1479
|
-
args.privilegedReason = undefined;
|
|
1480
|
-
}
|
|
1481
|
-
else {
|
|
1003
|
+
if (privilegedReasonLength !== -1) {
|
|
1482
1004
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1483
|
-
args.privilegedReason =
|
|
1484
|
-
}
|
|
1485
|
-
// Call the method
|
|
1486
|
-
const listResult = await this.wallet.listCertificates(args, originator);
|
|
1487
|
-
// Serialize the result
|
|
1488
|
-
const resultWriter = new index_js_1.Utils.Writer();
|
|
1489
|
-
// totalCertificates
|
|
1490
|
-
resultWriter.writeVarIntNum(listResult.totalCertificates);
|
|
1491
|
-
// certificates
|
|
1492
|
-
for (const cert of listResult.certificates) {
|
|
1493
|
-
const certificate = new Certificate_js_1.default(cert.type, cert.serialNumber, cert.subject, cert.certifier, cert.revocationOutpoint, cert.fields, cert.signature);
|
|
1494
|
-
const certBin = certificate.toBinary();
|
|
1495
|
-
// Write certificate binary length and data
|
|
1496
|
-
resultWriter.writeVarIntNum(certBin.length);
|
|
1497
|
-
resultWriter.write(certBin);
|
|
1498
|
-
}
|
|
1499
|
-
// Return the response
|
|
1500
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1501
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1502
|
-
responseWriter.write(resultWriter.toArray());
|
|
1503
|
-
return responseWriter.toArray();
|
|
1504
|
-
}
|
|
1505
|
-
case 'proveCertificate':
|
|
1506
|
-
{
|
|
1507
|
-
const args = {};
|
|
1508
|
-
// Read certificate
|
|
1509
|
-
const cert = {};
|
|
1510
|
-
// Read type
|
|
1511
|
-
const typeBytes = paramsReader.read(32);
|
|
1512
|
-
cert.type = index_js_1.Utils.toBase64(typeBytes);
|
|
1513
|
-
// Read subject
|
|
1514
|
-
const subjectBytes = paramsReader.read(33);
|
|
1515
|
-
cert.subject = index_js_1.Utils.toHex(subjectBytes);
|
|
1516
|
-
// Read serialNumber
|
|
1517
|
-
const serialNumberBytes = paramsReader.read(32);
|
|
1518
|
-
cert.serialNumber = index_js_1.Utils.toBase64(serialNumberBytes);
|
|
1519
|
-
// Read certifier
|
|
1520
|
-
const certifierBytes = paramsReader.read(33);
|
|
1521
|
-
cert.certifier = index_js_1.Utils.toHex(certifierBytes);
|
|
1522
|
-
// Read revocationOutpoint
|
|
1523
|
-
cert.revocationOutpoint = this.decodeOutpoint(paramsReader);
|
|
1524
|
-
// Read signature
|
|
1525
|
-
const signatureLength = paramsReader.readVarIntNum();
|
|
1526
|
-
const signatureBytes = paramsReader.read(signatureLength);
|
|
1527
|
-
cert.signature = index_js_1.Utils.toHex(signatureBytes);
|
|
1528
|
-
// Read fields
|
|
1529
|
-
const fieldsLength = paramsReader.readVarIntNum();
|
|
1530
|
-
cert.fields = {};
|
|
1531
|
-
for (let i = 0; i < fieldsLength; i++) {
|
|
1532
|
-
const fieldNameLength = paramsReader.readVarIntNum();
|
|
1533
|
-
const fieldNameBytes = paramsReader.read(fieldNameLength);
|
|
1534
|
-
const fieldName = index_js_1.Utils.toUTF8(fieldNameBytes);
|
|
1535
|
-
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1536
|
-
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1537
|
-
const fieldValue = index_js_1.Utils.toUTF8(fieldValueBytes);
|
|
1538
|
-
cert.fields[fieldName] = fieldValue;
|
|
1539
|
-
}
|
|
1540
|
-
args.certificate = cert;
|
|
1541
|
-
// Read fields to reveal
|
|
1542
|
-
const fieldsToRevealLength = paramsReader.readVarIntNum();
|
|
1543
|
-
args.fieldsToReveal = [];
|
|
1544
|
-
for (let i = 0; i < fieldsToRevealLength; i++) {
|
|
1545
|
-
const fieldNameLength = paramsReader.readVarIntNum();
|
|
1546
|
-
const fieldNameBytes = paramsReader.read(fieldNameLength);
|
|
1547
|
-
const fieldName = index_js_1.Utils.toUTF8(fieldNameBytes);
|
|
1548
|
-
args.fieldsToReveal.push(fieldName);
|
|
1549
|
-
}
|
|
1550
|
-
// Read verifier
|
|
1551
|
-
const verifierBytes = paramsReader.read(33);
|
|
1552
|
-
args.verifier = index_js_1.Utils.toHex(verifierBytes);
|
|
1553
|
-
// Read privileged parameters
|
|
1554
|
-
const privilegedFlag = paramsReader.readInt8();
|
|
1555
|
-
if (privilegedFlag === -1) {
|
|
1556
|
-
args.privileged = undefined;
|
|
1005
|
+
args.privilegedReason = index_1.Utils.toUTF8(privilegedReasonBytes);
|
|
1557
1006
|
}
|
|
1558
1007
|
else {
|
|
1559
|
-
args.privileged = privilegedFlag === 1;
|
|
1560
|
-
}
|
|
1561
|
-
const privilegedReasonLength = paramsReader.readInt8();
|
|
1562
|
-
if (privilegedReasonLength === -1) {
|
|
1563
1008
|
args.privilegedReason = undefined;
|
|
1564
1009
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
{
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
args.
|
|
1595
|
-
|
|
1010
|
+
}
|
|
1011
|
+
// Deserialize seekPermission
|
|
1012
|
+
const seekPermission = paramsReader.readInt8();
|
|
1013
|
+
if (seekPermission >= 0) {
|
|
1014
|
+
args.seekPermission = seekPermission === 1;
|
|
1015
|
+
}
|
|
1016
|
+
else {
|
|
1017
|
+
args.seekPermission = undefined;
|
|
1018
|
+
}
|
|
1019
|
+
// Call the method
|
|
1020
|
+
const getPublicKeyResult = await this.wallet.getPublicKey(args, originator);
|
|
1021
|
+
// Serialize the result
|
|
1022
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1023
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1024
|
+
const publicKeyBytes = index_1.Utils.toArray(getPublicKeyResult.publicKey, "hex");
|
|
1025
|
+
responseWriter.write(publicKeyBytes);
|
|
1026
|
+
return responseWriter.toArray();
|
|
1027
|
+
}
|
|
1028
|
+
case "encrypt": {
|
|
1029
|
+
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1030
|
+
// Deserialize plaintext
|
|
1031
|
+
const plaintextLength = paramsReader.readVarIntNum();
|
|
1032
|
+
args.plaintext = paramsReader.read(plaintextLength);
|
|
1033
|
+
// Deserialize seekPermission
|
|
1034
|
+
const seekPermission = paramsReader.readInt8();
|
|
1035
|
+
if (seekPermission >= 0) {
|
|
1036
|
+
args.seekPermission = seekPermission === 1;
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
args.seekPermission = undefined;
|
|
1040
|
+
}
|
|
1041
|
+
// Call the method
|
|
1042
|
+
const encryptResult = await this.wallet.encrypt(args, originator);
|
|
1043
|
+
// Serialize the result
|
|
1044
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1045
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1046
|
+
responseWriter.write(encryptResult.ciphertext);
|
|
1047
|
+
return responseWriter.toArray();
|
|
1048
|
+
}
|
|
1049
|
+
case "decrypt": {
|
|
1050
|
+
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1051
|
+
// Deserialize ciphertext
|
|
1052
|
+
const ciphertextLength = paramsReader.readVarIntNum();
|
|
1053
|
+
args.ciphertext = paramsReader.read(ciphertextLength);
|
|
1054
|
+
// Deserialize seekPermission
|
|
1055
|
+
const seekPermission = paramsReader.readInt8();
|
|
1056
|
+
if (seekPermission >= 0) {
|
|
1057
|
+
args.seekPermission = seekPermission === 1;
|
|
1058
|
+
}
|
|
1059
|
+
else {
|
|
1060
|
+
args.seekPermission = undefined;
|
|
1061
|
+
}
|
|
1062
|
+
// Call the method
|
|
1063
|
+
const decryptResult = await this.wallet.decrypt(args, originator);
|
|
1064
|
+
// Serialize the result
|
|
1065
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1066
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1067
|
+
responseWriter.write(decryptResult.plaintext);
|
|
1068
|
+
return responseWriter.toArray();
|
|
1069
|
+
}
|
|
1070
|
+
case "createHmac": {
|
|
1071
|
+
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1072
|
+
// Deserialize data
|
|
1073
|
+
const dataLength = paramsReader.readVarIntNum();
|
|
1074
|
+
args.data = paramsReader.read(dataLength);
|
|
1075
|
+
// Deserialize seekPermission
|
|
1076
|
+
const seekPermission = paramsReader.readInt8();
|
|
1077
|
+
if (seekPermission >= 0) {
|
|
1078
|
+
args.seekPermission = seekPermission === 1;
|
|
1079
|
+
}
|
|
1080
|
+
else {
|
|
1081
|
+
args.seekPermission = undefined;
|
|
1082
|
+
}
|
|
1083
|
+
// Call the method
|
|
1084
|
+
const createHmacResult = await this.wallet.createHmac(args, originator);
|
|
1085
|
+
// Serialize the result
|
|
1086
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1087
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1088
|
+
responseWriter.write(createHmacResult.hmac);
|
|
1089
|
+
return responseWriter.toArray();
|
|
1090
|
+
}
|
|
1091
|
+
case "verifyHmac": {
|
|
1092
|
+
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1093
|
+
// Deserialize hmac
|
|
1094
|
+
args.hmac = paramsReader.read(32);
|
|
1095
|
+
// Deserialize data
|
|
1096
|
+
const dataLength = paramsReader.readVarIntNum();
|
|
1097
|
+
args.data = paramsReader.read(dataLength);
|
|
1098
|
+
// Deserialize seekPermission
|
|
1099
|
+
const seekPermission = paramsReader.readInt8();
|
|
1100
|
+
if (seekPermission >= 0) {
|
|
1101
|
+
args.seekPermission = seekPermission === 1;
|
|
1102
|
+
}
|
|
1103
|
+
else {
|
|
1104
|
+
args.seekPermission = undefined;
|
|
1105
|
+
}
|
|
1106
|
+
// Call the method
|
|
1107
|
+
await this.wallet.verifyHmac(args, originator);
|
|
1108
|
+
// Serialize the result (no data to return)
|
|
1109
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1110
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1111
|
+
return responseWriter.toArray();
|
|
1112
|
+
}
|
|
1113
|
+
case "createSignature": {
|
|
1114
|
+
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1115
|
+
// Deserialize data or hashToDirectlySign
|
|
1116
|
+
const dataTypeFlag = paramsReader.readUInt8();
|
|
1117
|
+
if (dataTypeFlag === 1) {
|
|
1118
|
+
const dataLength = paramsReader.readVarIntNum();
|
|
1119
|
+
args.data = paramsReader.read(dataLength);
|
|
1120
|
+
}
|
|
1121
|
+
else if (dataTypeFlag === 2) {
|
|
1122
|
+
args.hashToDirectlySign = paramsReader.read(32);
|
|
1123
|
+
}
|
|
1124
|
+
// Deserialize seekPermission
|
|
1125
|
+
const seekPermission = paramsReader.readInt8();
|
|
1126
|
+
if (seekPermission >= 0) {
|
|
1127
|
+
args.seekPermission = seekPermission === 1;
|
|
1128
|
+
}
|
|
1129
|
+
else {
|
|
1130
|
+
args.seekPermission = undefined;
|
|
1131
|
+
}
|
|
1132
|
+
// Call the method
|
|
1133
|
+
const createSignatureResult = await this.wallet.createSignature(args, originator);
|
|
1134
|
+
// Serialize the result
|
|
1135
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1136
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1137
|
+
responseWriter.write(createSignatureResult.signature);
|
|
1138
|
+
return responseWriter.toArray();
|
|
1139
|
+
}
|
|
1140
|
+
case "verifySignature": {
|
|
1141
|
+
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1142
|
+
// Deserialize forSelf
|
|
1143
|
+
const forSelfFlag = paramsReader.readInt8();
|
|
1144
|
+
if (forSelfFlag === -1) {
|
|
1145
|
+
args.forSelf = undefined;
|
|
1146
|
+
}
|
|
1147
|
+
else {
|
|
1148
|
+
args.forSelf = forSelfFlag === 1;
|
|
1149
|
+
}
|
|
1150
|
+
// Deserialize signature
|
|
1151
|
+
const signatureLength = paramsReader.readVarIntNum();
|
|
1152
|
+
args.signature = paramsReader.read(signatureLength);
|
|
1153
|
+
// Deserialize data or hashToDirectlyVerify
|
|
1154
|
+
const dataTypeFlag = paramsReader.readUInt8();
|
|
1155
|
+
if (dataTypeFlag === 1) {
|
|
1156
|
+
const dataLength = paramsReader.readVarIntNum();
|
|
1157
|
+
args.data = paramsReader.read(dataLength);
|
|
1158
|
+
}
|
|
1159
|
+
else if (dataTypeFlag === 2) {
|
|
1160
|
+
args.hashToDirectlyVerify = paramsReader.read(32);
|
|
1161
|
+
}
|
|
1162
|
+
// Deserialize seekPermission
|
|
1163
|
+
const seekPermission = paramsReader.readInt8();
|
|
1164
|
+
if (seekPermission >= 0) {
|
|
1165
|
+
args.seekPermission = seekPermission === 1;
|
|
1166
|
+
}
|
|
1167
|
+
else {
|
|
1168
|
+
args.seekPermission = undefined;
|
|
1169
|
+
}
|
|
1170
|
+
// Call the method
|
|
1171
|
+
await this.wallet.verifySignature(args, originator);
|
|
1172
|
+
// Serialize the result (no data to return)
|
|
1173
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1174
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1175
|
+
return responseWriter.toArray();
|
|
1176
|
+
}
|
|
1177
|
+
case "isAuthenticated": {
|
|
1178
|
+
// No parameters to deserialize
|
|
1179
|
+
// Call the method
|
|
1180
|
+
const isAuthenticatedResult = await this.wallet.isAuthenticated({}, originator);
|
|
1181
|
+
// Serialize the result
|
|
1182
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1183
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1184
|
+
responseWriter.writeUInt8(isAuthenticatedResult.authenticated ? 1 : 0);
|
|
1185
|
+
return responseWriter.toArray();
|
|
1186
|
+
}
|
|
1187
|
+
case "waitForAuthentication": {
|
|
1188
|
+
// No parameters to deserialize
|
|
1189
|
+
// Call the method
|
|
1190
|
+
await this.wallet.waitForAuthentication({}, originator);
|
|
1191
|
+
// Serialize the result (authenticated is always true)
|
|
1192
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1193
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1194
|
+
return responseWriter.toArray();
|
|
1195
|
+
}
|
|
1196
|
+
case "getHeight": {
|
|
1197
|
+
// No parameters to deserialize
|
|
1198
|
+
// Call the method
|
|
1199
|
+
const getHeightResult = await this.wallet.getHeight({}, originator);
|
|
1200
|
+
// Serialize the result
|
|
1201
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1202
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1203
|
+
responseWriter.writeVarIntNum(getHeightResult.height);
|
|
1204
|
+
return responseWriter.toArray();
|
|
1205
|
+
}
|
|
1206
|
+
case "getHeaderForHeight": {
|
|
1207
|
+
const args = {};
|
|
1208
|
+
// Deserialize height
|
|
1209
|
+
args.height = paramsReader.readVarIntNum();
|
|
1210
|
+
// Call the method
|
|
1211
|
+
const getHeaderResult = await this.wallet.getHeaderForHeight(args, originator);
|
|
1212
|
+
// Serialize the result
|
|
1213
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1214
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1215
|
+
const headerBytes = index_1.Utils.toArray(getHeaderResult.header, "hex");
|
|
1216
|
+
responseWriter.write(headerBytes);
|
|
1217
|
+
return responseWriter.toArray();
|
|
1218
|
+
}
|
|
1219
|
+
case "getNetwork": {
|
|
1220
|
+
// No parameters to deserialize
|
|
1221
|
+
// Call the method
|
|
1222
|
+
const getNetworkResult = await this.wallet.getNetwork({}, originator);
|
|
1223
|
+
// Serialize the result
|
|
1224
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1225
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1226
|
+
responseWriter.writeUInt8(getNetworkResult.network === "mainnet" ? 0 : 1);
|
|
1227
|
+
return responseWriter.toArray();
|
|
1228
|
+
}
|
|
1229
|
+
case "getVersion": {
|
|
1230
|
+
// No parameters to deserialize
|
|
1231
|
+
// Call the method
|
|
1232
|
+
const getVersionResult = await this.wallet.getVersion({}, originator);
|
|
1233
|
+
// Serialize the result
|
|
1234
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1235
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1236
|
+
const versionBytes = index_1.Utils.toArray(getVersionResult.version, "utf8");
|
|
1237
|
+
responseWriter.write(versionBytes);
|
|
1238
|
+
return responseWriter.toArray();
|
|
1239
|
+
}
|
|
1240
|
+
case "revealCounterpartyKeyLinkage": {
|
|
1241
|
+
const args = {};
|
|
1242
|
+
// Read privileged parameters
|
|
1243
|
+
const privilegedFlag = paramsReader.readInt8();
|
|
1244
|
+
if (privilegedFlag === -1) {
|
|
1245
|
+
args.privileged = undefined;
|
|
1246
|
+
}
|
|
1247
|
+
else {
|
|
1248
|
+
args.privileged = privilegedFlag === 1;
|
|
1249
|
+
}
|
|
1250
|
+
const privilegedReasonLength = paramsReader.readInt8();
|
|
1251
|
+
if (privilegedReasonLength === -1) {
|
|
1252
|
+
args.privilegedReason = undefined;
|
|
1253
|
+
}
|
|
1254
|
+
else {
|
|
1255
|
+
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1256
|
+
args.privilegedReason = index_1.Utils.toUTF8(privilegedReasonBytes);
|
|
1257
|
+
}
|
|
1258
|
+
// Read counterparty public key
|
|
1259
|
+
const counterpartyBytes = paramsReader.read(33);
|
|
1260
|
+
args.counterparty = index_1.Utils.toHex(counterpartyBytes);
|
|
1261
|
+
// Read verifier public key
|
|
1262
|
+
const verifierBytes = paramsReader.read(33);
|
|
1263
|
+
args.verifier = index_1.Utils.toHex(verifierBytes);
|
|
1264
|
+
// Call the method
|
|
1265
|
+
const revealResult = await this.wallet.revealCounterpartyKeyLinkage(args, originator);
|
|
1266
|
+
// Serialize the result
|
|
1267
|
+
const resultWriter = new index_1.Utils.Writer();
|
|
1268
|
+
// Write prover
|
|
1269
|
+
resultWriter.write(index_1.Utils.toArray(revealResult.prover, "hex"));
|
|
1270
|
+
// Write verifier
|
|
1271
|
+
resultWriter.write(index_1.Utils.toArray(revealResult.verifier, "hex"));
|
|
1272
|
+
// Write counterparty
|
|
1273
|
+
resultWriter.write(index_1.Utils.toArray(revealResult.counterparty, "hex"));
|
|
1274
|
+
// Write revelationTime
|
|
1275
|
+
const revelationTimeBytes = index_1.Utils.toArray(revealResult.revelationTime, "utf8");
|
|
1276
|
+
resultWriter.writeVarIntNum(revelationTimeBytes.length);
|
|
1277
|
+
resultWriter.write(revelationTimeBytes);
|
|
1278
|
+
// Write encryptedLinkage
|
|
1279
|
+
resultWriter.writeVarIntNum(revealResult.encryptedLinkage.length);
|
|
1280
|
+
resultWriter.write(revealResult.encryptedLinkage);
|
|
1281
|
+
// Write encryptedLinkageProof
|
|
1282
|
+
resultWriter.writeVarIntNum(revealResult.encryptedLinkageProof.length);
|
|
1283
|
+
resultWriter.write(revealResult.encryptedLinkageProof);
|
|
1284
|
+
// Return success code and result
|
|
1285
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1286
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1287
|
+
responseWriter.write(resultWriter.toArray());
|
|
1288
|
+
return responseWriter.toArray();
|
|
1289
|
+
}
|
|
1290
|
+
case "revealSpecificKeyLinkage": {
|
|
1291
|
+
// Deserialize key-related parameters and privileged parameters
|
|
1292
|
+
const args = this.decodeKeyRelatedParams(paramsReader);
|
|
1293
|
+
// Read verifier public key
|
|
1294
|
+
const verifierBytes = paramsReader.read(33);
|
|
1295
|
+
args.verifier = index_1.Utils.toHex(verifierBytes);
|
|
1296
|
+
// Call the method
|
|
1297
|
+
const revealResult = await this.wallet.revealSpecificKeyLinkage(args, originator);
|
|
1298
|
+
// Serialize the result
|
|
1299
|
+
const resultWriter = new index_1.Utils.Writer();
|
|
1300
|
+
// Write prover
|
|
1301
|
+
resultWriter.write(index_1.Utils.toArray(revealResult.prover, "hex"));
|
|
1302
|
+
// Write verifier
|
|
1303
|
+
resultWriter.write(index_1.Utils.toArray(revealResult.verifier, "hex"));
|
|
1304
|
+
// Write counterparty
|
|
1305
|
+
resultWriter.write(index_1.Utils.toArray(revealResult.counterparty, "hex"));
|
|
1306
|
+
// Write securityLevel
|
|
1307
|
+
resultWriter.writeUInt8(revealResult.protocolID[0]);
|
|
1308
|
+
// Write protocol string
|
|
1309
|
+
const protocolBytesOut = index_1.Utils.toArray(revealResult.protocolID[1], "utf8");
|
|
1310
|
+
resultWriter.writeVarIntNum(protocolBytesOut.length);
|
|
1311
|
+
resultWriter.write(protocolBytesOut);
|
|
1312
|
+
// Write keyID
|
|
1313
|
+
const keyIDBytesOut = index_1.Utils.toArray(revealResult.keyID, "utf8");
|
|
1314
|
+
resultWriter.writeVarIntNum(keyIDBytesOut.length);
|
|
1315
|
+
resultWriter.write(keyIDBytesOut);
|
|
1316
|
+
// Write encryptedLinkage
|
|
1317
|
+
resultWriter.writeVarIntNum(revealResult.encryptedLinkage.length);
|
|
1318
|
+
resultWriter.write(revealResult.encryptedLinkage);
|
|
1319
|
+
// Write encryptedLinkageProof
|
|
1320
|
+
resultWriter.writeVarIntNum(revealResult.encryptedLinkageProof.length);
|
|
1321
|
+
resultWriter.write(revealResult.encryptedLinkageProof);
|
|
1322
|
+
// Write proofType
|
|
1323
|
+
resultWriter.writeUInt8(revealResult.proofType);
|
|
1324
|
+
// Return success code and result
|
|
1325
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1326
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1327
|
+
responseWriter.write(resultWriter.toArray());
|
|
1328
|
+
return responseWriter.toArray();
|
|
1329
|
+
}
|
|
1330
|
+
case "acquireCertificate": {
|
|
1331
|
+
const args = {};
|
|
1332
|
+
// Read args.type
|
|
1333
|
+
const typeBytes = paramsReader.read(32);
|
|
1334
|
+
args.type = index_1.Utils.toBase64(typeBytes);
|
|
1335
|
+
// args.certifier
|
|
1336
|
+
const certifierBytes = paramsReader.read(33);
|
|
1337
|
+
args.certifier = index_1.Utils.toHex(certifierBytes);
|
|
1338
|
+
// Read fields
|
|
1339
|
+
const fieldsLength = paramsReader.readVarIntNum();
|
|
1340
|
+
args.fields = {};
|
|
1341
|
+
for (let i = 0; i < fieldsLength; i++) {
|
|
1342
|
+
const fieldNameLength = paramsReader.readVarIntNum();
|
|
1343
|
+
const fieldNameBytes = paramsReader.read(fieldNameLength);
|
|
1344
|
+
const fieldName = index_1.Utils.toUTF8(fieldNameBytes);
|
|
1345
|
+
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1346
|
+
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1347
|
+
const fieldValue = index_1.Utils.toUTF8(fieldValueBytes);
|
|
1348
|
+
args.fields[fieldName] = fieldValue;
|
|
1349
|
+
}
|
|
1350
|
+
// Read privileged parameters
|
|
1351
|
+
const privilegedFlag = paramsReader.readInt8();
|
|
1352
|
+
if (privilegedFlag === -1) {
|
|
1353
|
+
args.privileged = undefined;
|
|
1354
|
+
}
|
|
1355
|
+
else {
|
|
1356
|
+
args.privileged = privilegedFlag === 1;
|
|
1357
|
+
}
|
|
1358
|
+
const privilegedReasonLength = paramsReader.readInt8();
|
|
1359
|
+
if (privilegedReasonLength === -1) {
|
|
1360
|
+
args.privilegedReason = undefined;
|
|
1361
|
+
}
|
|
1362
|
+
else {
|
|
1363
|
+
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1364
|
+
args.privilegedReason = index_1.Utils.toUTF8(privilegedReasonBytes);
|
|
1365
|
+
}
|
|
1366
|
+
// Read acquisitionProtocol
|
|
1367
|
+
const acquisitionProtocolFlag = paramsReader.readUInt8();
|
|
1368
|
+
args.acquisitionProtocol =
|
|
1369
|
+
acquisitionProtocolFlag === 1 ? "direct" : "issuance";
|
|
1370
|
+
if (args.acquisitionProtocol === "direct") {
|
|
1371
|
+
// args.serialNumber
|
|
1596
1372
|
const serialNumberBytes = paramsReader.read(32);
|
|
1597
|
-
args.serialNumber =
|
|
1598
|
-
//
|
|
1599
|
-
|
|
1600
|
-
args.
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
case 'discoverByIdentityKey':
|
|
1609
|
-
{
|
|
1610
|
-
const args = {};
|
|
1611
|
-
// Read identityKey
|
|
1612
|
-
const identityKeyBytes = paramsReader.read(33);
|
|
1613
|
-
args.identityKey = index_js_1.Utils.toHex(identityKeyBytes);
|
|
1614
|
-
// Read limit and offset
|
|
1615
|
-
const limit = paramsReader.readVarIntNum();
|
|
1616
|
-
if (limit >= 0) {
|
|
1617
|
-
args.limit = limit;
|
|
1618
|
-
}
|
|
1619
|
-
else {
|
|
1620
|
-
args.limit = undefined;
|
|
1621
|
-
}
|
|
1622
|
-
const offset = paramsReader.readVarIntNum();
|
|
1623
|
-
if (offset >= 0) {
|
|
1624
|
-
args.offset = offset;
|
|
1373
|
+
args.serialNumber = index_1.Utils.toBase64(serialNumberBytes);
|
|
1374
|
+
// args.revocationOutpoint
|
|
1375
|
+
args.revocationOutpoint = this.decodeOutpoint(paramsReader);
|
|
1376
|
+
// args.signature
|
|
1377
|
+
const signatureLength = paramsReader.readVarIntNum();
|
|
1378
|
+
const signatureBytes = paramsReader.read(signatureLength);
|
|
1379
|
+
args.signature = index_1.Utils.toHex(signatureBytes);
|
|
1380
|
+
// args.keyringRevealer
|
|
1381
|
+
const keyringRevealerIdentifier = paramsReader.readUInt8();
|
|
1382
|
+
if (keyringRevealerIdentifier === 11) {
|
|
1383
|
+
args.keyringRevealer = "certifier";
|
|
1625
1384
|
}
|
|
1626
1385
|
else {
|
|
1627
|
-
|
|
1386
|
+
const keyringRevealerBytes = [keyringRevealerIdentifier].concat(paramsReader.read(32));
|
|
1387
|
+
args.keyringRevealer = index_1.Utils.toHex(keyringRevealerBytes);
|
|
1628
1388
|
}
|
|
1629
|
-
//
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
}
|
|
1634
|
-
else {
|
|
1635
|
-
args.seekPermission = undefined;
|
|
1636
|
-
}
|
|
1637
|
-
// Call the method
|
|
1638
|
-
const discoverResult = await this.wallet.discoverByIdentityKey(args, originator);
|
|
1639
|
-
// Serialize the result
|
|
1640
|
-
const result = this.serializeDiscoveryResult(discoverResult);
|
|
1641
|
-
// Return the response
|
|
1642
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1643
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1644
|
-
responseWriter.write(result);
|
|
1645
|
-
return responseWriter.toArray();
|
|
1646
|
-
}
|
|
1647
|
-
case 'discoverByAttributes':
|
|
1648
|
-
{
|
|
1649
|
-
const args = {};
|
|
1650
|
-
// Read attributes
|
|
1651
|
-
const attributesLength = paramsReader.readVarIntNum();
|
|
1652
|
-
args.attributes = {};
|
|
1653
|
-
for (let i = 0; i < attributesLength; i++) {
|
|
1389
|
+
// args.keyringForSubject
|
|
1390
|
+
const keyringEntriesLength = paramsReader.readVarIntNum();
|
|
1391
|
+
args.keyringForSubject = {};
|
|
1392
|
+
for (let i = 0; i < keyringEntriesLength; i++) {
|
|
1654
1393
|
const fieldKeyLength = paramsReader.readVarIntNum();
|
|
1655
1394
|
const fieldKeyBytes = paramsReader.read(fieldKeyLength);
|
|
1656
|
-
const fieldKey =
|
|
1395
|
+
const fieldKey = index_1.Utils.toUTF8(fieldKeyBytes);
|
|
1657
1396
|
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1658
1397
|
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1659
|
-
const fieldValue =
|
|
1660
|
-
args.
|
|
1661
|
-
}
|
|
1662
|
-
// Read limit and offset
|
|
1663
|
-
const limit = paramsReader.readVarIntNum();
|
|
1664
|
-
if (limit >= 0) {
|
|
1665
|
-
args.limit = limit;
|
|
1666
|
-
}
|
|
1667
|
-
else {
|
|
1668
|
-
args.limit = undefined;
|
|
1669
|
-
}
|
|
1670
|
-
const offset = paramsReader.readVarIntNum();
|
|
1671
|
-
if (offset >= 0) {
|
|
1672
|
-
args.offset = offset;
|
|
1398
|
+
const fieldValue = index_1.Utils.toBase64(fieldValueBytes);
|
|
1399
|
+
args.keyringForSubject[fieldKey] = fieldValue;
|
|
1673
1400
|
}
|
|
1674
|
-
else {
|
|
1675
|
-
args.offset = undefined;
|
|
1676
|
-
}
|
|
1677
|
-
// Deserialize seekPermission
|
|
1678
|
-
const seekPermission = paramsReader.readInt8();
|
|
1679
|
-
if (seekPermission >= 0) {
|
|
1680
|
-
args.seekPermission = seekPermission === 1;
|
|
1681
|
-
}
|
|
1682
|
-
else {
|
|
1683
|
-
args.seekPermission = undefined;
|
|
1684
|
-
}
|
|
1685
|
-
// Call the method
|
|
1686
|
-
const discoverResult = await this.wallet.discoverByAttributes(args, originator);
|
|
1687
|
-
// Serialize the result
|
|
1688
|
-
const result = this.serializeDiscoveryResult(discoverResult);
|
|
1689
|
-
// Return the response
|
|
1690
|
-
const responseWriter = new index_js_1.Utils.Writer();
|
|
1691
|
-
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1692
|
-
responseWriter.write(result);
|
|
1693
|
-
return responseWriter.toArray();
|
|
1694
1401
|
}
|
|
1402
|
+
else {
|
|
1403
|
+
// args.certifierUrl
|
|
1404
|
+
const certifierUrlLength = paramsReader.readVarIntNum();
|
|
1405
|
+
const certifierUrlBytes = paramsReader.read(certifierUrlLength);
|
|
1406
|
+
args.certifierUrl = index_1.Utils.toUTF8(certifierUrlBytes);
|
|
1407
|
+
}
|
|
1408
|
+
// Call the method
|
|
1409
|
+
const acquireResult = await this.wallet.acquireCertificate(args, originator);
|
|
1410
|
+
// Serialize the certificate (assuming Certificate class is available)
|
|
1411
|
+
const cert = new Certificate_1.default(acquireResult.type, acquireResult.serialNumber, acquireResult.subject, acquireResult.certifier, acquireResult.revocationOutpoint, acquireResult.fields, acquireResult.signature);
|
|
1412
|
+
const certBin = cert.toBinary();
|
|
1413
|
+
// Return success code and certificate binary
|
|
1414
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1415
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1416
|
+
responseWriter.write(certBin);
|
|
1417
|
+
return responseWriter.toArray();
|
|
1418
|
+
}
|
|
1419
|
+
case "listCertificates": {
|
|
1420
|
+
const args = {};
|
|
1421
|
+
// Read certifiers
|
|
1422
|
+
const certifiersLength = paramsReader.readVarIntNum();
|
|
1423
|
+
args.certifiers = [];
|
|
1424
|
+
for (let i = 0; i < certifiersLength; i++) {
|
|
1425
|
+
const certifierBytes = paramsReader.read(33);
|
|
1426
|
+
args.certifiers.push(index_1.Utils.toHex(certifierBytes));
|
|
1427
|
+
}
|
|
1428
|
+
// Read types
|
|
1429
|
+
const typesLength = paramsReader.readVarIntNum();
|
|
1430
|
+
args.types = [];
|
|
1431
|
+
for (let i = 0; i < typesLength; i++) {
|
|
1432
|
+
const typeBytes = paramsReader.read(32);
|
|
1433
|
+
args.types.push(index_1.Utils.toBase64(typeBytes));
|
|
1434
|
+
}
|
|
1435
|
+
// Read limit and offset
|
|
1436
|
+
const limit = paramsReader.readVarIntNum();
|
|
1437
|
+
if (limit >= 0) {
|
|
1438
|
+
args.limit = limit;
|
|
1439
|
+
}
|
|
1440
|
+
else {
|
|
1441
|
+
args.limit = undefined;
|
|
1442
|
+
}
|
|
1443
|
+
const offset = paramsReader.readVarIntNum();
|
|
1444
|
+
if (offset >= 0) {
|
|
1445
|
+
args.offset = offset;
|
|
1446
|
+
}
|
|
1447
|
+
else {
|
|
1448
|
+
args.offset = undefined;
|
|
1449
|
+
}
|
|
1450
|
+
// Read privileged parameters
|
|
1451
|
+
const privilegedFlag = paramsReader.readInt8();
|
|
1452
|
+
if (privilegedFlag === -1) {
|
|
1453
|
+
args.privileged = undefined;
|
|
1454
|
+
}
|
|
1455
|
+
else {
|
|
1456
|
+
args.privileged = privilegedFlag === 1;
|
|
1457
|
+
}
|
|
1458
|
+
const privilegedReasonLength = paramsReader.readInt8();
|
|
1459
|
+
if (privilegedReasonLength === -1) {
|
|
1460
|
+
args.privilegedReason = undefined;
|
|
1461
|
+
}
|
|
1462
|
+
else {
|
|
1463
|
+
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1464
|
+
args.privilegedReason = index_1.Utils.toUTF8(privilegedReasonBytes);
|
|
1465
|
+
}
|
|
1466
|
+
// Call the method
|
|
1467
|
+
const listResult = await this.wallet.listCertificates(args, originator);
|
|
1468
|
+
// Serialize the result
|
|
1469
|
+
const resultWriter = new index_1.Utils.Writer();
|
|
1470
|
+
// totalCertificates
|
|
1471
|
+
resultWriter.writeVarIntNum(listResult.totalCertificates);
|
|
1472
|
+
// certificates
|
|
1473
|
+
for (const cert of listResult.certificates) {
|
|
1474
|
+
const certificate = new Certificate_1.default(cert.type, cert.serialNumber, cert.subject, cert.certifier, cert.revocationOutpoint, cert.fields, cert.signature);
|
|
1475
|
+
const certBin = certificate.toBinary();
|
|
1476
|
+
// Write certificate binary length and data
|
|
1477
|
+
resultWriter.writeVarIntNum(certBin.length);
|
|
1478
|
+
resultWriter.write(certBin);
|
|
1479
|
+
}
|
|
1480
|
+
// Return the response
|
|
1481
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1482
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1483
|
+
responseWriter.write(resultWriter.toArray());
|
|
1484
|
+
return responseWriter.toArray();
|
|
1485
|
+
}
|
|
1486
|
+
case "proveCertificate": {
|
|
1487
|
+
const args = {};
|
|
1488
|
+
// Read certificate
|
|
1489
|
+
const cert = {};
|
|
1490
|
+
// Read type
|
|
1491
|
+
const typeBytes = paramsReader.read(32);
|
|
1492
|
+
cert.type = index_1.Utils.toBase64(typeBytes);
|
|
1493
|
+
// Read subject
|
|
1494
|
+
const subjectBytes = paramsReader.read(33);
|
|
1495
|
+
cert.subject = index_1.Utils.toHex(subjectBytes);
|
|
1496
|
+
// Read serialNumber
|
|
1497
|
+
const serialNumberBytes = paramsReader.read(32);
|
|
1498
|
+
cert.serialNumber = index_1.Utils.toBase64(serialNumberBytes);
|
|
1499
|
+
// Read certifier
|
|
1500
|
+
const certifierBytes = paramsReader.read(33);
|
|
1501
|
+
cert.certifier = index_1.Utils.toHex(certifierBytes);
|
|
1502
|
+
// Read revocationOutpoint
|
|
1503
|
+
cert.revocationOutpoint = this.decodeOutpoint(paramsReader);
|
|
1504
|
+
// Read signature
|
|
1505
|
+
const signatureLength = paramsReader.readVarIntNum();
|
|
1506
|
+
const signatureBytes = paramsReader.read(signatureLength);
|
|
1507
|
+
cert.signature = index_1.Utils.toHex(signatureBytes);
|
|
1508
|
+
// Read fields
|
|
1509
|
+
const fieldsLength = paramsReader.readVarIntNum();
|
|
1510
|
+
cert.fields = {};
|
|
1511
|
+
for (let i = 0; i < fieldsLength; i++) {
|
|
1512
|
+
const fieldNameLength = paramsReader.readVarIntNum();
|
|
1513
|
+
const fieldNameBytes = paramsReader.read(fieldNameLength);
|
|
1514
|
+
const fieldName = index_1.Utils.toUTF8(fieldNameBytes);
|
|
1515
|
+
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1516
|
+
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1517
|
+
const fieldValue = index_1.Utils.toUTF8(fieldValueBytes);
|
|
1518
|
+
cert.fields[fieldName] = fieldValue;
|
|
1519
|
+
}
|
|
1520
|
+
args.certificate = cert;
|
|
1521
|
+
// Read fields to reveal
|
|
1522
|
+
const fieldsToRevealLength = paramsReader.readVarIntNum();
|
|
1523
|
+
args.fieldsToReveal = [];
|
|
1524
|
+
for (let i = 0; i < fieldsToRevealLength; i++) {
|
|
1525
|
+
const fieldNameLength = paramsReader.readVarIntNum();
|
|
1526
|
+
const fieldNameBytes = paramsReader.read(fieldNameLength);
|
|
1527
|
+
const fieldName = index_1.Utils.toUTF8(fieldNameBytes);
|
|
1528
|
+
args.fieldsToReveal.push(fieldName);
|
|
1529
|
+
}
|
|
1530
|
+
// Read verifier
|
|
1531
|
+
const verifierBytes = paramsReader.read(33);
|
|
1532
|
+
args.verifier = index_1.Utils.toHex(verifierBytes);
|
|
1533
|
+
// Read privileged parameters
|
|
1534
|
+
const privilegedFlag = paramsReader.readInt8();
|
|
1535
|
+
if (privilegedFlag === -1) {
|
|
1536
|
+
args.privileged = undefined;
|
|
1537
|
+
}
|
|
1538
|
+
else {
|
|
1539
|
+
args.privileged = privilegedFlag === 1;
|
|
1540
|
+
}
|
|
1541
|
+
const privilegedReasonLength = paramsReader.readInt8();
|
|
1542
|
+
if (privilegedReasonLength === -1) {
|
|
1543
|
+
args.privilegedReason = undefined;
|
|
1544
|
+
}
|
|
1545
|
+
else {
|
|
1546
|
+
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1547
|
+
args.privilegedReason = index_1.Utils.toUTF8(privilegedReasonBytes);
|
|
1548
|
+
}
|
|
1549
|
+
// Call the method
|
|
1550
|
+
const proveResult = await this.wallet.proveCertificate(args, originator);
|
|
1551
|
+
// Serialize keyringForVerifier
|
|
1552
|
+
const resultWriter = new index_1.Utils.Writer();
|
|
1553
|
+
const keyringEntries = Object.entries(proveResult.keyringForVerifier);
|
|
1554
|
+
resultWriter.writeVarIntNum(keyringEntries.length);
|
|
1555
|
+
for (const [fieldName, fieldValue] of keyringEntries) {
|
|
1556
|
+
const fieldNameBytes = index_1.Utils.toArray(fieldName, "utf8");
|
|
1557
|
+
resultWriter.writeVarIntNum(fieldNameBytes.length);
|
|
1558
|
+
resultWriter.write(fieldNameBytes);
|
|
1559
|
+
const fieldValueBytes = index_1.Utils.toArray(fieldValue, "base64");
|
|
1560
|
+
resultWriter.writeVarIntNum(fieldValueBytes.length);
|
|
1561
|
+
resultWriter.write(fieldValueBytes);
|
|
1562
|
+
}
|
|
1563
|
+
// Return the response
|
|
1564
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1565
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1566
|
+
responseWriter.write(resultWriter.toArray());
|
|
1567
|
+
return responseWriter.toArray();
|
|
1568
|
+
}
|
|
1569
|
+
case "relinquishCertificate": {
|
|
1570
|
+
const args = {};
|
|
1571
|
+
// Read type
|
|
1572
|
+
const typeBytes = paramsReader.read(32);
|
|
1573
|
+
args.type = index_1.Utils.toBase64(typeBytes);
|
|
1574
|
+
// Read serialNumber
|
|
1575
|
+
const serialNumberBytes = paramsReader.read(32);
|
|
1576
|
+
args.serialNumber = index_1.Utils.toBase64(serialNumberBytes);
|
|
1577
|
+
// Read certifier
|
|
1578
|
+
const certifierBytes = paramsReader.read(33);
|
|
1579
|
+
args.certifier = index_1.Utils.toHex(certifierBytes);
|
|
1580
|
+
// Call the method
|
|
1581
|
+
await this.wallet.relinquishCertificate(args, originator);
|
|
1582
|
+
// Return success code
|
|
1583
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1584
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1585
|
+
return responseWriter.toArray();
|
|
1586
|
+
}
|
|
1587
|
+
case "discoverByIdentityKey": {
|
|
1588
|
+
const args = {};
|
|
1589
|
+
// Read identityKey
|
|
1590
|
+
const identityKeyBytes = paramsReader.read(33);
|
|
1591
|
+
args.identityKey = index_1.Utils.toHex(identityKeyBytes);
|
|
1592
|
+
// Read limit and offset
|
|
1593
|
+
const limit = paramsReader.readVarIntNum();
|
|
1594
|
+
if (limit >= 0) {
|
|
1595
|
+
args.limit = limit;
|
|
1596
|
+
}
|
|
1597
|
+
else {
|
|
1598
|
+
args.limit = undefined;
|
|
1599
|
+
}
|
|
1600
|
+
const offset = paramsReader.readVarIntNum();
|
|
1601
|
+
if (offset >= 0) {
|
|
1602
|
+
args.offset = offset;
|
|
1603
|
+
}
|
|
1604
|
+
else {
|
|
1605
|
+
args.offset = undefined;
|
|
1606
|
+
}
|
|
1607
|
+
// Deserialize seekPermission
|
|
1608
|
+
const seekPermission = paramsReader.readInt8();
|
|
1609
|
+
if (seekPermission >= 0) {
|
|
1610
|
+
args.seekPermission = seekPermission === 1;
|
|
1611
|
+
}
|
|
1612
|
+
else {
|
|
1613
|
+
args.seekPermission = undefined;
|
|
1614
|
+
}
|
|
1615
|
+
// Call the method
|
|
1616
|
+
const discoverResult = await this.wallet.discoverByIdentityKey(args, originator);
|
|
1617
|
+
// Serialize the result
|
|
1618
|
+
const result = this.serializeDiscoveryResult(discoverResult);
|
|
1619
|
+
// Return the response
|
|
1620
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1621
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1622
|
+
responseWriter.write(result);
|
|
1623
|
+
return responseWriter.toArray();
|
|
1624
|
+
}
|
|
1625
|
+
case "discoverByAttributes": {
|
|
1626
|
+
const args = {};
|
|
1627
|
+
// Read attributes
|
|
1628
|
+
const attributesLength = paramsReader.readVarIntNum();
|
|
1629
|
+
args.attributes = {};
|
|
1630
|
+
for (let i = 0; i < attributesLength; i++) {
|
|
1631
|
+
const fieldKeyLength = paramsReader.readVarIntNum();
|
|
1632
|
+
const fieldKeyBytes = paramsReader.read(fieldKeyLength);
|
|
1633
|
+
const fieldKey = index_1.Utils.toUTF8(fieldKeyBytes);
|
|
1634
|
+
const fieldValueLength = paramsReader.readVarIntNum();
|
|
1635
|
+
const fieldValueBytes = paramsReader.read(fieldValueLength);
|
|
1636
|
+
const fieldValue = index_1.Utils.toUTF8(fieldValueBytes);
|
|
1637
|
+
args.attributes[fieldKey] = fieldValue;
|
|
1638
|
+
}
|
|
1639
|
+
// Read limit and offset
|
|
1640
|
+
const limit = paramsReader.readVarIntNum();
|
|
1641
|
+
if (limit >= 0) {
|
|
1642
|
+
args.limit = limit;
|
|
1643
|
+
}
|
|
1644
|
+
else {
|
|
1645
|
+
args.limit = undefined;
|
|
1646
|
+
}
|
|
1647
|
+
const offset = paramsReader.readVarIntNum();
|
|
1648
|
+
if (offset >= 0) {
|
|
1649
|
+
args.offset = offset;
|
|
1650
|
+
}
|
|
1651
|
+
else {
|
|
1652
|
+
args.offset = undefined;
|
|
1653
|
+
}
|
|
1654
|
+
// Deserialize seekPermission
|
|
1655
|
+
const seekPermission = paramsReader.readInt8();
|
|
1656
|
+
if (seekPermission >= 0) {
|
|
1657
|
+
args.seekPermission = seekPermission === 1;
|
|
1658
|
+
}
|
|
1659
|
+
else {
|
|
1660
|
+
args.seekPermission = undefined;
|
|
1661
|
+
}
|
|
1662
|
+
// Call the method
|
|
1663
|
+
const discoverResult = await this.wallet.discoverByAttributes(args, originator);
|
|
1664
|
+
// Serialize the result
|
|
1665
|
+
const result = this.serializeDiscoveryResult(discoverResult);
|
|
1666
|
+
// Return the response
|
|
1667
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1668
|
+
responseWriter.writeUInt8(0); // errorByte = 0
|
|
1669
|
+
responseWriter.write(result);
|
|
1670
|
+
return responseWriter.toArray();
|
|
1671
|
+
}
|
|
1695
1672
|
default:
|
|
1696
1673
|
throw new Error(`Method ${callName} not implemented`);
|
|
1697
1674
|
}
|
|
1698
1675
|
}
|
|
1699
1676
|
catch (err) {
|
|
1700
|
-
const responseWriter = new
|
|
1701
|
-
responseWriter.writeUInt8(
|
|
1677
|
+
const responseWriter = new index_1.Utils.Writer();
|
|
1678
|
+
responseWriter.writeUInt8(err.code || 1); // errorCode = 1 (generic error)
|
|
1702
1679
|
// Serialize the error message
|
|
1703
|
-
const errorMessage = err.message ||
|
|
1704
|
-
const errorMessageBytes =
|
|
1680
|
+
const errorMessage = err.message || "Unknown error";
|
|
1681
|
+
const errorMessageBytes = index_1.Utils.toArray(errorMessage, "utf8");
|
|
1705
1682
|
responseWriter.writeVarIntNum(errorMessageBytes.length);
|
|
1706
1683
|
responseWriter.write(errorMessageBytes);
|
|
1707
1684
|
// Serialize the stack trace
|
|
1708
|
-
const stackTrace = err.stack ||
|
|
1709
|
-
const stackTraceBytes =
|
|
1685
|
+
const stackTrace = err.stack || "";
|
|
1686
|
+
const stackTraceBytes = index_1.Utils.toArray(stackTrace, "utf8");
|
|
1710
1687
|
responseWriter.writeVarIntNum(stackTraceBytes.length);
|
|
1711
1688
|
responseWriter.write(stackTraceBytes);
|
|
1712
1689
|
return responseWriter.toArray();
|
|
@@ -1716,50 +1693,50 @@ class WalletWireProcessor {
|
|
|
1716
1693
|
const securityLevel = reader.readUInt8();
|
|
1717
1694
|
const protocolLength = reader.readVarIntNum();
|
|
1718
1695
|
const protocolBytes = reader.read(protocolLength);
|
|
1719
|
-
const protocolString =
|
|
1696
|
+
const protocolString = index_1.Utils.toUTF8(protocolBytes);
|
|
1720
1697
|
return [securityLevel, protocolString];
|
|
1721
1698
|
}
|
|
1722
1699
|
decodeString(reader) {
|
|
1723
1700
|
const length = reader.readVarIntNum();
|
|
1724
1701
|
const bytes = reader.read(length);
|
|
1725
|
-
return
|
|
1702
|
+
return index_1.Utils.toUTF8(bytes);
|
|
1726
1703
|
}
|
|
1727
1704
|
decodeCounterparty(reader) {
|
|
1728
1705
|
const counterpartyFlag = reader.readUInt8();
|
|
1729
1706
|
if (counterpartyFlag === 11) {
|
|
1730
|
-
return
|
|
1707
|
+
return "self";
|
|
1731
1708
|
}
|
|
1732
1709
|
else if (counterpartyFlag === 12) {
|
|
1733
|
-
return
|
|
1710
|
+
return "anyone";
|
|
1734
1711
|
}
|
|
1735
1712
|
else if (counterpartyFlag === 0) {
|
|
1736
1713
|
return undefined;
|
|
1737
1714
|
}
|
|
1738
1715
|
else {
|
|
1739
1716
|
const counterpartyRemainingBytes = reader.read(32);
|
|
1740
|
-
return
|
|
1717
|
+
return index_1.Utils.toHex([counterpartyFlag, ...counterpartyRemainingBytes]);
|
|
1741
1718
|
}
|
|
1742
1719
|
}
|
|
1743
1720
|
serializeDiscoveryResult(discoverResult) {
|
|
1744
|
-
const resultWriter = new
|
|
1721
|
+
const resultWriter = new index_1.Utils.Writer();
|
|
1745
1722
|
// totalCertificates
|
|
1746
1723
|
resultWriter.writeVarIntNum(discoverResult.totalCertificates);
|
|
1747
1724
|
// certificates
|
|
1748
1725
|
for (const cert of discoverResult.certificates) {
|
|
1749
1726
|
// Serialize certificate binary
|
|
1750
|
-
const certificate = new
|
|
1727
|
+
const certificate = new Certificate_1.default(cert.type, cert.serialNumber, cert.subject, cert.certifier, cert.revocationOutpoint, cert.fields, cert.signaturre);
|
|
1751
1728
|
const certBin = certificate.toBinary();
|
|
1752
1729
|
// Write certificate binary length and data
|
|
1753
1730
|
resultWriter.writeVarIntNum(certBin.length);
|
|
1754
1731
|
resultWriter.write(certBin);
|
|
1755
1732
|
// Serialize certifierInfo
|
|
1756
|
-
const nameBytes =
|
|
1733
|
+
const nameBytes = index_1.Utils.toArray(cert.certifierInfo.name, "utf8");
|
|
1757
1734
|
resultWriter.writeVarIntNum(nameBytes.length);
|
|
1758
1735
|
resultWriter.write(nameBytes);
|
|
1759
|
-
const iconUrlBytes =
|
|
1736
|
+
const iconUrlBytes = index_1.Utils.toArray(cert.certifierInfo.iconUrl, "utf8");
|
|
1760
1737
|
resultWriter.writeVarIntNum(iconUrlBytes.length);
|
|
1761
1738
|
resultWriter.write(iconUrlBytes);
|
|
1762
|
-
const descriptionBytes =
|
|
1739
|
+
const descriptionBytes = index_1.Utils.toArray(cert.certifierInfo.description, "utf8");
|
|
1763
1740
|
resultWriter.writeVarIntNum(descriptionBytes.length);
|
|
1764
1741
|
resultWriter.write(descriptionBytes);
|
|
1765
1742
|
resultWriter.writeUInt8(cert.certifierInfo.trust);
|
|
@@ -1767,10 +1744,10 @@ class WalletWireProcessor {
|
|
|
1767
1744
|
const publicKeyringEntries = Object.entries(cert.publiclyRevealedKeyring);
|
|
1768
1745
|
resultWriter.writeVarIntNum(publicKeyringEntries.length);
|
|
1769
1746
|
for (const [fieldName, fieldValue] of publicKeyringEntries) {
|
|
1770
|
-
const fieldNameBytes =
|
|
1747
|
+
const fieldNameBytes = index_1.Utils.toArray(fieldName, "utf8");
|
|
1771
1748
|
resultWriter.writeVarIntNum(fieldNameBytes.length);
|
|
1772
1749
|
resultWriter.write(fieldNameBytes);
|
|
1773
|
-
const fieldValueBytes =
|
|
1750
|
+
const fieldValueBytes = index_1.Utils.toArray(fieldValue, "base64");
|
|
1774
1751
|
resultWriter.writeVarIntNum(fieldValueBytes.length);
|
|
1775
1752
|
resultWriter.write(fieldValueBytes);
|
|
1776
1753
|
}
|
|
@@ -1778,10 +1755,10 @@ class WalletWireProcessor {
|
|
|
1778
1755
|
const decryptedFieldEntries = Object.entries(cert.decryptedFields);
|
|
1779
1756
|
resultWriter.writeVarIntNum(decryptedFieldEntries.length);
|
|
1780
1757
|
for (const [fieldName, fieldValue] of decryptedFieldEntries) {
|
|
1781
|
-
const fieldNameBytes =
|
|
1758
|
+
const fieldNameBytes = index_1.Utils.toArray(fieldName, "utf8");
|
|
1782
1759
|
resultWriter.writeVarIntNum(fieldNameBytes.length);
|
|
1783
1760
|
resultWriter.write(fieldNameBytes);
|
|
1784
|
-
const fieldValueBytes =
|
|
1761
|
+
const fieldValueBytes = index_1.Utils.toArray(fieldValue, "utf8");
|
|
1785
1762
|
resultWriter.writeVarIntNum(fieldValueBytes.length);
|
|
1786
1763
|
resultWriter.write(fieldValueBytes);
|
|
1787
1764
|
}
|
|
@@ -1795,7 +1772,7 @@ class WalletWireProcessor {
|
|
|
1795
1772
|
// Read keyID
|
|
1796
1773
|
const keyIDLength = paramsReader.readVarIntNum();
|
|
1797
1774
|
const keyIDBytes = paramsReader.read(keyIDLength);
|
|
1798
|
-
args.keyID =
|
|
1775
|
+
args.keyID = index_1.Utils.toUTF8(keyIDBytes);
|
|
1799
1776
|
// Read counterparty
|
|
1800
1777
|
args.counterparty = this.decodeCounterparty(paramsReader);
|
|
1801
1778
|
// Read privileged parameters
|
|
@@ -1812,7 +1789,7 @@ class WalletWireProcessor {
|
|
|
1812
1789
|
}
|
|
1813
1790
|
else {
|
|
1814
1791
|
const privilegedReasonBytes = paramsReader.read(privilegedReasonLength);
|
|
1815
|
-
args.privilegedReason =
|
|
1792
|
+
args.privilegedReason = index_1.Utils.toUTF8(privilegedReasonBytes);
|
|
1816
1793
|
}
|
|
1817
1794
|
return args;
|
|
1818
1795
|
}
|