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