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