@bsv/sdk 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/auth/Peer.js +8 -13
- package/dist/cjs/src/auth/Peer.js.map +1 -1
- package/dist/cjs/src/auth/SessionManager.js +4 -7
- package/dist/cjs/src/auth/SessionManager.js.map +1 -1
- package/dist/cjs/src/auth/certificates/MasterCertificate.js +1 -1
- package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js +1 -1
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js +32 -32
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +4 -4
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/cjs/src/compat/ECIES.js +29 -34
- package/dist/cjs/src/compat/ECIES.js.map +1 -1
- package/dist/cjs/src/compat/HD.js +9 -4
- package/dist/cjs/src/compat/HD.js.map +1 -1
- package/dist/cjs/src/compat/Mnemonic.js +12 -12
- package/dist/cjs/src/compat/Mnemonic.js.map +1 -1
- package/dist/cjs/src/identity/ContactsManager.js +172 -232
- package/dist/cjs/src/identity/ContactsManager.js.map +1 -1
- package/dist/cjs/src/identity/IdentityClient.js +122 -55
- package/dist/cjs/src/identity/IdentityClient.js.map +1 -1
- package/dist/cjs/src/kvstore/GlobalKVStore.js +30 -31
- package/dist/cjs/src/kvstore/GlobalKVStore.js.map +1 -1
- package/dist/cjs/src/kvstore/LocalKVStore.js +9 -9
- package/dist/cjs/src/kvstore/LocalKVStore.js.map +1 -1
- package/dist/cjs/src/kvstore/kvStoreInterpreter.js +2 -2
- package/dist/cjs/src/kvstore/kvStoreInterpreter.js.map +1 -1
- package/dist/cjs/src/messages/SignedMessage.js +1 -1
- package/dist/cjs/src/messages/SignedMessage.js.map +1 -1
- package/dist/cjs/src/overlay-tools/Historian.js +1 -1
- package/dist/cjs/src/overlay-tools/Historian.js.map +1 -1
- package/dist/cjs/src/overlay-tools/LookupResolver.js +139 -46
- package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js +75 -146
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/cjs/src/primitives/AESGCM.js +2 -2
- package/dist/cjs/src/primitives/AESGCM.js.map +1 -1
- package/dist/cjs/src/primitives/BigNumber.js +164 -148
- package/dist/cjs/src/primitives/BigNumber.js.map +1 -1
- package/dist/cjs/src/primitives/Curve.js +17 -15
- package/dist/cjs/src/primitives/Curve.js.map +1 -1
- package/dist/cjs/src/primitives/ECDSA.js +12 -7
- package/dist/cjs/src/primitives/ECDSA.js.map +1 -1
- package/dist/cjs/src/primitives/Hash.js +140 -56
- package/dist/cjs/src/primitives/Hash.js.map +1 -1
- package/dist/cjs/src/primitives/JacobianPoint.js +8 -8
- package/dist/cjs/src/primitives/JacobianPoint.js.map +1 -1
- package/dist/cjs/src/primitives/K256.js +3 -3
- package/dist/cjs/src/primitives/K256.js.map +1 -1
- package/dist/cjs/src/primitives/Point.js +36 -40
- package/dist/cjs/src/primitives/Point.js.map +1 -1
- package/dist/cjs/src/primitives/PrivateKey.js +4 -4
- package/dist/cjs/src/primitives/PrivateKey.js.map +1 -1
- package/dist/cjs/src/primitives/PublicKey.js +4 -4
- package/dist/cjs/src/primitives/PublicKey.js.map +1 -1
- package/dist/cjs/src/primitives/Random.js +10 -14
- package/dist/cjs/src/primitives/Random.js.map +1 -1
- package/dist/cjs/src/primitives/ReaderUint8Array.js +6 -6
- package/dist/cjs/src/primitives/ReaderUint8Array.js.map +1 -1
- package/dist/cjs/src/primitives/Schnorr.js +2 -2
- package/dist/cjs/src/primitives/Schnorr.js.map +1 -1
- package/dist/cjs/src/primitives/Secp256r1.js +2 -1
- package/dist/cjs/src/primitives/Secp256r1.js.map +1 -1
- package/dist/cjs/src/primitives/Signature.js +8 -8
- package/dist/cjs/src/primitives/Signature.js.map +1 -1
- package/dist/cjs/src/primitives/TransactionSignature.js +20 -21
- package/dist/cjs/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/cjs/src/primitives/utils.js +39 -46
- package/dist/cjs/src/primitives/utils.js.map +1 -1
- package/dist/cjs/src/registry/RegistryClient.js +31 -23
- package/dist/cjs/src/registry/RegistryClient.js.map +1 -1
- package/dist/cjs/src/remittance/RemittanceManager.js +19 -18
- package/dist/cjs/src/remittance/RemittanceManager.js.map +1 -1
- package/dist/cjs/src/remittance/modules/BasicBRC29.js.map +1 -1
- package/dist/cjs/src/script/Script.js +93 -170
- package/dist/cjs/src/script/Script.js.map +1 -1
- package/dist/cjs/src/script/ScriptEvaluationError.js +2 -2
- package/dist/cjs/src/script/ScriptEvaluationError.js.map +1 -1
- package/dist/cjs/src/script/Spend.js +14 -12
- package/dist/cjs/src/script/Spend.js.map +1 -1
- package/dist/cjs/src/script/templates/PushDrop.js +22 -18
- package/dist/cjs/src/script/templates/PushDrop.js.map +1 -1
- package/dist/cjs/src/script/templates/RPuzzle.js +2 -4
- package/dist/cjs/src/script/templates/RPuzzle.js.map +1 -1
- package/dist/cjs/src/storage/StorageDownloader.js +42 -9
- package/dist/cjs/src/storage/StorageDownloader.js.map +1 -1
- package/dist/cjs/src/totp/totp.js +1 -1
- package/dist/cjs/src/totp/totp.js.map +1 -1
- package/dist/cjs/src/transaction/Beef.js +239 -192
- package/dist/cjs/src/transaction/Beef.js.map +1 -1
- package/dist/cjs/src/transaction/BeefConstants.js +19 -0
- package/dist/cjs/src/transaction/BeefConstants.js.map +1 -0
- package/dist/cjs/src/transaction/BeefTx.js +12 -12
- package/dist/cjs/src/transaction/BeefTx.js.map +1 -1
- package/dist/cjs/src/transaction/MerklePath.js +4 -4
- package/dist/cjs/src/transaction/MerklePath.js.map +1 -1
- package/dist/cjs/src/transaction/Transaction.js +49 -52
- package/dist/cjs/src/transaction/Transaction.js.map +1 -1
- package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js +1 -1
- package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
- package/dist/cjs/src/transaction/http/BinaryFetchClient.js +9 -9
- package/dist/cjs/src/transaction/http/BinaryFetchClient.js.map +1 -1
- package/dist/cjs/src/transaction/http/DefaultHttpClient.js +9 -9
- package/dist/cjs/src/transaction/http/DefaultHttpClient.js.map +1 -1
- package/dist/cjs/src/wallet/CachedKeyDeriver.js +1 -1
- package/dist/cjs/src/wallet/CachedKeyDeriver.js.map +1 -1
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/src/wallet/WalletError.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +5 -4
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/ReactNativeWebView.js +9 -9
- package/dist/cjs/src/wallet/substrates/ReactNativeWebView.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +92 -92
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +387 -711
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/XDM.js +4 -4
- package/dist/cjs/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/window.CWI.js +2 -2
- package/dist/cjs/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/cjs/src/wallet/validationHelpers.js +9 -9
- package/dist/cjs/src/wallet/validationHelpers.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/auth/Peer.js +25 -13
- package/dist/esm/src/auth/Peer.js.map +1 -1
- package/dist/esm/src/auth/SessionManager.js +4 -7
- package/dist/esm/src/auth/SessionManager.js.map +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js +32 -32
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +4 -4
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/esm/src/compat/ECIES.js +29 -34
- package/dist/esm/src/compat/ECIES.js.map +1 -1
- package/dist/esm/src/compat/HD.js +9 -4
- package/dist/esm/src/compat/HD.js.map +1 -1
- package/dist/esm/src/compat/Mnemonic.js +12 -12
- package/dist/esm/src/compat/Mnemonic.js.map +1 -1
- package/dist/esm/src/identity/ContactsManager.js +172 -232
- package/dist/esm/src/identity/ContactsManager.js.map +1 -1
- package/dist/esm/src/identity/IdentityClient.js +122 -55
- package/dist/esm/src/identity/IdentityClient.js.map +1 -1
- package/dist/esm/src/kvstore/GlobalKVStore.js +30 -31
- package/dist/esm/src/kvstore/GlobalKVStore.js.map +1 -1
- package/dist/esm/src/kvstore/LocalKVStore.js +9 -9
- package/dist/esm/src/kvstore/LocalKVStore.js.map +1 -1
- package/dist/esm/src/kvstore/kvStoreInterpreter.js +2 -2
- package/dist/esm/src/kvstore/kvStoreInterpreter.js.map +1 -1
- package/dist/esm/src/messages/SignedMessage.js +1 -1
- package/dist/esm/src/messages/SignedMessage.js.map +1 -1
- package/dist/esm/src/overlay-tools/Historian.js +1 -1
- package/dist/esm/src/overlay-tools/Historian.js.map +1 -1
- package/dist/esm/src/overlay-tools/LookupResolver.js +139 -46
- package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js +74 -146
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/esm/src/primitives/AESGCM.js +2 -2
- package/dist/esm/src/primitives/AESGCM.js.map +1 -1
- package/dist/esm/src/primitives/BigNumber.js +167 -154
- package/dist/esm/src/primitives/BigNumber.js.map +1 -1
- package/dist/esm/src/primitives/Curve.js +17 -15
- package/dist/esm/src/primitives/Curve.js.map +1 -1
- package/dist/esm/src/primitives/ECDSA.js +12 -7
- package/dist/esm/src/primitives/ECDSA.js.map +1 -1
- package/dist/esm/src/primitives/Hash.js +140 -56
- package/dist/esm/src/primitives/Hash.js.map +1 -1
- package/dist/esm/src/primitives/JacobianPoint.js +8 -8
- package/dist/esm/src/primitives/JacobianPoint.js.map +1 -1
- package/dist/esm/src/primitives/K256.js +3 -3
- package/dist/esm/src/primitives/K256.js.map +1 -1
- package/dist/esm/src/primitives/Point.js +36 -40
- package/dist/esm/src/primitives/Point.js.map +1 -1
- package/dist/esm/src/primitives/PrivateKey.js +4 -4
- package/dist/esm/src/primitives/PrivateKey.js.map +1 -1
- package/dist/esm/src/primitives/PublicKey.js +4 -4
- package/dist/esm/src/primitives/PublicKey.js.map +1 -1
- package/dist/esm/src/primitives/Random.js +10 -14
- package/dist/esm/src/primitives/Random.js.map +1 -1
- package/dist/esm/src/primitives/ReaderUint8Array.js +6 -6
- package/dist/esm/src/primitives/ReaderUint8Array.js.map +1 -1
- package/dist/esm/src/primitives/Schnorr.js +1 -1
- package/dist/esm/src/primitives/Schnorr.js.map +1 -1
- package/dist/esm/src/primitives/Secp256r1.js +2 -1
- package/dist/esm/src/primitives/Secp256r1.js.map +1 -1
- package/dist/esm/src/primitives/Signature.js +8 -8
- package/dist/esm/src/primitives/Signature.js.map +1 -1
- package/dist/esm/src/primitives/TransactionSignature.js +20 -21
- package/dist/esm/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/esm/src/primitives/utils.js +39 -48
- package/dist/esm/src/primitives/utils.js.map +1 -1
- package/dist/esm/src/registry/RegistryClient.js +31 -23
- package/dist/esm/src/registry/RegistryClient.js.map +1 -1
- package/dist/esm/src/remittance/RemittanceManager.js +19 -18
- package/dist/esm/src/remittance/RemittanceManager.js.map +1 -1
- package/dist/esm/src/remittance/modules/BasicBRC29.js.map +1 -1
- package/dist/esm/src/script/Script.js +93 -170
- package/dist/esm/src/script/Script.js.map +1 -1
- package/dist/esm/src/script/ScriptEvaluationError.js +2 -2
- package/dist/esm/src/script/ScriptEvaluationError.js.map +1 -1
- package/dist/esm/src/script/Spend.js +14 -12
- package/dist/esm/src/script/Spend.js.map +1 -1
- package/dist/esm/src/script/templates/PushDrop.js +4 -3
- package/dist/esm/src/script/templates/PushDrop.js.map +1 -1
- package/dist/esm/src/script/templates/RPuzzle.js +2 -4
- package/dist/esm/src/script/templates/RPuzzle.js.map +1 -1
- package/dist/esm/src/storage/StorageDownloader.js +1 -1
- package/dist/esm/src/storage/StorageDownloader.js.map +1 -1
- package/dist/esm/src/totp/totp.js +1 -1
- package/dist/esm/src/totp/totp.js.map +1 -1
- package/dist/esm/src/transaction/Beef.js +229 -186
- package/dist/esm/src/transaction/Beef.js.map +1 -1
- package/dist/esm/src/transaction/BeefConstants.js +16 -0
- package/dist/esm/src/transaction/BeefConstants.js.map +1 -0
- package/dist/esm/src/transaction/BeefTx.js +3 -3
- package/dist/esm/src/transaction/BeefTx.js.map +1 -1
- package/dist/esm/src/transaction/MerklePath.js +4 -4
- package/dist/esm/src/transaction/MerklePath.js.map +1 -1
- package/dist/esm/src/transaction/Transaction.js +49 -52
- package/dist/esm/src/transaction/Transaction.js.map +1 -1
- package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js +1 -1
- package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
- package/dist/esm/src/transaction/http/BinaryFetchClient.js +9 -9
- package/dist/esm/src/transaction/http/BinaryFetchClient.js.map +1 -1
- package/dist/esm/src/transaction/http/DefaultHttpClient.js +9 -9
- package/dist/esm/src/transaction/http/DefaultHttpClient.js.map +1 -1
- package/dist/esm/src/wallet/CachedKeyDeriver.js +1 -1
- package/dist/esm/src/wallet/CachedKeyDeriver.js.map +1 -1
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/src/wallet/WalletError.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +5 -4
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/esm/src/wallet/substrates/ReactNativeWebView.js +9 -9
- package/dist/esm/src/wallet/substrates/ReactNativeWebView.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +92 -92
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +387 -711
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/esm/src/wallet/substrates/XDM.js +4 -4
- package/dist/esm/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/esm/src/wallet/substrates/window.CWI.js +2 -2
- package/dist/esm/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/esm/src/wallet/validationHelpers.js +9 -9
- package/dist/esm/src/wallet/validationHelpers.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/auth/Peer.d.ts +13 -0
- package/dist/types/src/auth/Peer.d.ts.map +1 -1
- package/dist/types/src/auth/SessionManager.d.ts.map +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/src/compat/ECIES.d.ts.map +1 -1
- package/dist/types/src/compat/HD.d.ts.map +1 -1
- package/dist/types/src/identity/ContactsManager.d.ts +18 -0
- package/dist/types/src/identity/ContactsManager.d.ts.map +1 -1
- package/dist/types/src/identity/IdentityClient.d.ts +47 -8
- package/dist/types/src/identity/IdentityClient.d.ts.map +1 -1
- package/dist/types/src/kvstore/GlobalKVStore.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts +59 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts +18 -3
- package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts.map +1 -1
- package/dist/types/src/primitives/BigNumber.d.ts +13 -3
- package/dist/types/src/primitives/BigNumber.d.ts.map +1 -1
- package/dist/types/src/primitives/Curve.d.ts.map +1 -1
- package/dist/types/src/primitives/ECDSA.d.ts.map +1 -1
- package/dist/types/src/primitives/Hash.d.ts +3 -3
- package/dist/types/src/primitives/Hash.d.ts.map +1 -1
- package/dist/types/src/primitives/JacobianPoint.d.ts +3 -1
- package/dist/types/src/primitives/JacobianPoint.d.ts.map +1 -1
- package/dist/types/src/primitives/Point.d.ts.map +1 -1
- package/dist/types/src/primitives/Random.d.ts +2 -2
- package/dist/types/src/primitives/Random.d.ts.map +1 -1
- package/dist/types/src/primitives/ReaderUint8Array.d.ts.map +1 -1
- package/dist/types/src/primitives/Schnorr.d.ts +2 -1
- package/dist/types/src/primitives/Schnorr.d.ts.map +1 -1
- package/dist/types/src/primitives/Secp256r1.d.ts.map +1 -1
- package/dist/types/src/primitives/utils.d.ts +2 -4
- package/dist/types/src/primitives/utils.d.ts.map +1 -1
- package/dist/types/src/registry/RegistryClient.d.ts.map +1 -1
- package/dist/types/src/remittance/RemittanceManager.d.ts.map +1 -1
- package/dist/types/src/remittance/modules/BasicBRC29.d.ts.map +1 -1
- package/dist/types/src/script/Script.d.ts +15 -8
- package/dist/types/src/script/Script.d.ts.map +1 -1
- package/dist/types/src/script/Spend.d.ts.map +1 -1
- package/dist/types/src/script/templates/PushDrop.d.ts +3 -1
- 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/transaction/Beef.d.ts +46 -8
- package/dist/types/src/transaction/Beef.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefConstants.d.ts +15 -0
- package/dist/types/src/transaction/BeefConstants.d.ts.map +1 -0
- package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
- package/dist/types/src/wallet/CachedKeyDeriver.d.ts.map +1 -1
- package/dist/types/src/wallet/KeyDeriver.d.ts +1 -1
- package/dist/types/src/wallet/KeyDeriver.d.ts.map +1 -1
- package/dist/types/src/wallet/Wallet.interfaces.d.ts +2 -2
- package/dist/types/src/wallet/Wallet.interfaces.d.ts.map +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts +7 -7
- package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts +7 -7
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts +36 -7
- package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/window.CWI.d.ts +8 -8
- 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 +3 -3
- package/package.json +1 -1
- package/src/auth/Peer.ts +26 -13
- package/src/auth/SessionManager.ts +4 -7
- package/src/auth/certificates/MasterCertificate.ts +1 -1
- package/src/auth/certificates/__tests/CompletedProtoWallet.ts +1 -1
- package/src/auth/clients/AuthFetch.ts +41 -41
- package/src/auth/transports/SimplifiedFetchTransport.ts +4 -4
- package/src/compat/ECIES.ts +29 -34
- package/src/compat/HD.ts +10 -5
- package/src/compat/Mnemonic.ts +11 -11
- package/src/compat/__tests/HD.test.ts +19 -0
- package/src/identity/ContactsManager.ts +194 -257
- package/src/identity/IdentityClient.ts +155 -66
- package/src/identity/__tests/IdentityClient.test.ts +25 -1
- package/src/kvstore/GlobalKVStore.ts +31 -32
- package/src/kvstore/LocalKVStore.ts +8 -8
- package/src/kvstore/kvStoreInterpreter.ts +2 -2
- package/src/messages/SignedMessage.ts +1 -1
- package/src/overlay-tools/Historian.ts +1 -1
- package/src/overlay-tools/LookupResolver.ts +182 -45
- package/src/overlay-tools/SHIPBroadcaster.ts +92 -168
- package/src/primitives/AESGCM.ts +2 -2
- package/src/primitives/BigNumber.ts +122 -113
- package/src/primitives/Curve.ts +16 -15
- package/src/primitives/ECDSA.ts +10 -8
- package/src/primitives/Hash.ts +152 -53
- package/src/primitives/JacobianPoint.ts +13 -11
- package/src/primitives/K256.ts +3 -3
- package/src/primitives/Point.ts +35 -38
- package/src/primitives/PrivateKey.ts +3 -3
- package/src/primitives/PublicKey.ts +3 -3
- package/src/primitives/Random.ts +11 -14
- package/src/primitives/ReaderUint8Array.ts +7 -7
- package/src/primitives/Schnorr.ts +2 -1
- package/src/primitives/Secp256r1.ts +2 -1
- package/src/primitives/Signature.ts +8 -8
- package/src/primitives/TransactionSignature.ts +16 -16
- package/src/primitives/utils.ts +37 -47
- package/src/registry/RegistryClient.ts +25 -25
- package/src/remittance/RemittanceManager.ts +17 -18
- package/src/remittance/modules/BasicBRC29.ts +2 -5
- package/src/script/Script.ts +114 -170
- package/src/script/ScriptEvaluationError.ts +2 -2
- package/src/script/Spend.ts +14 -15
- package/src/script/templates/PushDrop.ts +5 -3
- package/src/script/templates/RPuzzle.ts +2 -4
- package/src/storage/StorageDownloader.ts +1 -1
- package/src/totp/totp.ts +1 -1
- package/src/transaction/Beef.ts +241 -203
- package/src/transaction/BeefConstants.ts +16 -0
- package/src/transaction/BeefTx.ts +3 -3
- package/src/transaction/MerklePath.ts +4 -4
- package/src/transaction/Transaction.ts +48 -51
- package/src/transaction/fee-models/SatoshisPerKilobyte.ts +1 -1
- package/src/transaction/http/BinaryFetchClient.ts +8 -8
- package/src/transaction/http/DefaultHttpClient.ts +8 -8
- package/src/wallet/CachedKeyDeriver.ts +8 -6
- package/src/wallet/KeyDeriver.ts +1 -1
- package/src/wallet/Wallet.interfaces.ts +2 -4
- package/src/wallet/WalletClient.ts +8 -8
- package/src/wallet/WalletError.ts +1 -1
- package/src/wallet/__tests/WalletClient.substrate.test.ts +10 -6
- package/src/wallet/substrates/HTTPWalletJSON.ts +22 -21
- package/src/wallet/substrates/ReactNativeWebView.ts +9 -9
- package/src/wallet/substrates/WalletWireProcessor.ts +83 -83
- package/src/wallet/substrates/WalletWireTransceiver.ts +528 -938
- package/src/wallet/substrates/XDM.ts +4 -4
- package/src/wallet/substrates/__tests/HTTPWalletJSON.test.ts +38 -25
- package/src/wallet/substrates/__tests/ReactNativeWebView.test.ts +174 -0
- package/src/wallet/substrates/__tests/window.CWI.test.ts +256 -0
- package/src/wallet/substrates/window.CWI.ts +10 -10
- package/src/wallet/validationHelpers.ts +9 -9
|
@@ -3,6 +3,16 @@ import Certificate from '../../auth/certificates/Certificate.js';
|
|
|
3
3
|
import * as Utils from '../../primitives/utils.js';
|
|
4
4
|
import calls from './WalletWireCalls.js';
|
|
5
5
|
import { WalletError } from '../WalletError.js';
|
|
6
|
+
const ACTION_STATUS_MAP = {
|
|
7
|
+
1: 'completed',
|
|
8
|
+
2: 'unprocessed',
|
|
9
|
+
3: 'sending',
|
|
10
|
+
4: 'unproven',
|
|
11
|
+
5: 'unsigned',
|
|
12
|
+
6: 'nosend',
|
|
13
|
+
7: 'nonfinal',
|
|
14
|
+
8: 'failed'
|
|
15
|
+
};
|
|
6
16
|
/**
|
|
7
17
|
* A way to make remote calls to a wallet over a wallet wire.
|
|
8
18
|
*/
|
|
@@ -45,259 +55,69 @@ export default class WalletWireTransceiver {
|
|
|
45
55
|
async createAction(args, originator) {
|
|
46
56
|
const paramWriter = new Utils.Writer();
|
|
47
57
|
// Serialize description
|
|
48
|
-
|
|
49
|
-
paramWriter.writeVarIntNum(descriptionBytes.length);
|
|
50
|
-
paramWriter.write(descriptionBytes);
|
|
58
|
+
this.writeUTF8(paramWriter, args.description);
|
|
51
59
|
// input BEEF
|
|
52
|
-
if (args.inputBEEF
|
|
60
|
+
if (args.inputBEEF == null) {
|
|
61
|
+
paramWriter.writeVarIntNum(-1);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
53
64
|
paramWriter.writeVarIntNum(args.inputBEEF.length);
|
|
54
65
|
paramWriter.write(args.inputBEEF);
|
|
55
66
|
}
|
|
56
|
-
|
|
67
|
+
// Serialize inputs
|
|
68
|
+
if (args.inputs == null) {
|
|
57
69
|
paramWriter.writeVarIntNum(-1);
|
|
58
70
|
}
|
|
59
|
-
|
|
60
|
-
if (args.inputs != null) {
|
|
71
|
+
else {
|
|
61
72
|
paramWriter.writeVarIntNum(args.inputs.length);
|
|
62
73
|
for (const input of args.inputs) {
|
|
63
|
-
|
|
64
|
-
paramWriter.write(this.encodeOutpoint(input.outpoint));
|
|
65
|
-
// unlockingScript / unlockingScriptLength
|
|
66
|
-
if (input.unlockingScript != null && input.unlockingScript !== '') {
|
|
67
|
-
const unlockingScriptBytes = Utils.toArray(input.unlockingScript, 'hex');
|
|
68
|
-
paramWriter.writeVarIntNum(unlockingScriptBytes.length);
|
|
69
|
-
paramWriter.write(unlockingScriptBytes);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
paramWriter.writeVarIntNum(-1);
|
|
73
|
-
paramWriter.writeVarIntNum(input.unlockingScriptLength ?? 0);
|
|
74
|
-
}
|
|
75
|
-
// inputDescription
|
|
76
|
-
const inputDescriptionBytes = Utils.toArray(input.inputDescription, 'utf8');
|
|
77
|
-
paramWriter.writeVarIntNum(inputDescriptionBytes.length);
|
|
78
|
-
paramWriter.write(inputDescriptionBytes);
|
|
79
|
-
// sequenceNumber
|
|
80
|
-
if (typeof input.sequenceNumber === 'number') {
|
|
81
|
-
paramWriter.writeVarIntNum(input.sequenceNumber);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
paramWriter.writeVarIntNum(-1);
|
|
85
|
-
}
|
|
74
|
+
this.serializeCreateActionInput(paramWriter, input);
|
|
86
75
|
}
|
|
87
76
|
}
|
|
88
|
-
|
|
77
|
+
// Serialize outputs
|
|
78
|
+
if (args.outputs == null) {
|
|
89
79
|
paramWriter.writeVarIntNum(-1);
|
|
90
80
|
}
|
|
91
|
-
|
|
92
|
-
if (args.outputs != null) {
|
|
81
|
+
else {
|
|
93
82
|
paramWriter.writeVarIntNum(args.outputs.length);
|
|
94
83
|
for (const output of args.outputs) {
|
|
95
|
-
|
|
96
|
-
const lockingScriptBytes = Utils.toArray(output.lockingScript, 'hex');
|
|
97
|
-
paramWriter.writeVarIntNum(lockingScriptBytes.length);
|
|
98
|
-
paramWriter.write(lockingScriptBytes);
|
|
99
|
-
// satoshis
|
|
100
|
-
paramWriter.writeVarIntNum(output.satoshis);
|
|
101
|
-
// outputDescription
|
|
102
|
-
const outputDescriptionBytes = Utils.toArray(output.outputDescription, 'utf8');
|
|
103
|
-
paramWriter.writeVarIntNum(outputDescriptionBytes.length);
|
|
104
|
-
paramWriter.write(outputDescriptionBytes);
|
|
105
|
-
// basket
|
|
106
|
-
if (output.basket != null && output.basket !== '') {
|
|
107
|
-
const basketBytes = Utils.toArray(output.basket, 'utf8');
|
|
108
|
-
paramWriter.writeVarIntNum(basketBytes.length);
|
|
109
|
-
paramWriter.write(basketBytes);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
paramWriter.writeVarIntNum(-1);
|
|
113
|
-
}
|
|
114
|
-
// customInstructions
|
|
115
|
-
if (output.customInstructions != null && output.customInstructions !== '') {
|
|
116
|
-
const customInstructionsBytes = Utils.toArray(output.customInstructions, 'utf8');
|
|
117
|
-
paramWriter.writeVarIntNum(customInstructionsBytes.length);
|
|
118
|
-
paramWriter.write(customInstructionsBytes);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
paramWriter.writeVarIntNum(-1);
|
|
122
|
-
}
|
|
123
|
-
// tags
|
|
124
|
-
if (output.tags != null) {
|
|
125
|
-
paramWriter.writeVarIntNum(output.tags.length);
|
|
126
|
-
for (const tag of output.tags) {
|
|
127
|
-
const tagBytes = Utils.toArray(tag, 'utf8');
|
|
128
|
-
paramWriter.writeVarIntNum(tagBytes.length);
|
|
129
|
-
paramWriter.write(tagBytes);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
paramWriter.writeVarIntNum(-1);
|
|
134
|
-
}
|
|
84
|
+
this.serializeCreateActionOutput(paramWriter, output);
|
|
135
85
|
}
|
|
136
86
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// Serialize lockTime
|
|
141
|
-
if (typeof args.lockTime === 'number') {
|
|
142
|
-
paramWriter.writeVarIntNum(args.lockTime);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
paramWriter.writeVarIntNum(-1);
|
|
146
|
-
}
|
|
147
|
-
// Serialize version
|
|
148
|
-
if (typeof args.version === 'number') {
|
|
149
|
-
paramWriter.writeVarIntNum(args.version);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
paramWriter.writeVarIntNum(-1);
|
|
153
|
-
}
|
|
87
|
+
// Serialize lockTime, version
|
|
88
|
+
this.writeOptionalVarInt(paramWriter, args.lockTime);
|
|
89
|
+
this.writeOptionalVarInt(paramWriter, args.version);
|
|
154
90
|
// Serialize labels
|
|
155
|
-
|
|
156
|
-
paramWriter.writeVarIntNum(args.labels.length);
|
|
157
|
-
for (const label of args.labels) {
|
|
158
|
-
const labelBytes = Utils.toArray(label, 'utf8');
|
|
159
|
-
paramWriter.writeVarIntNum(labelBytes.length);
|
|
160
|
-
paramWriter.write(labelBytes);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
paramWriter.writeVarIntNum(-1);
|
|
165
|
-
}
|
|
91
|
+
this.writeUTF8Array(paramWriter, args.labels);
|
|
166
92
|
// Serialize options
|
|
167
|
-
|
|
168
|
-
paramWriter.writeInt8(1); // options present
|
|
169
|
-
// signAndProcess
|
|
170
|
-
if (typeof args.options.signAndProcess === 'boolean') {
|
|
171
|
-
paramWriter.writeInt8(args.options.signAndProcess ? 1 : 0);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
paramWriter.writeInt8(-1);
|
|
175
|
-
}
|
|
176
|
-
// acceptDelayedBroadcast
|
|
177
|
-
if (typeof args.options.acceptDelayedBroadcast === 'boolean') {
|
|
178
|
-
paramWriter.writeInt8(args.options.acceptDelayedBroadcast ? 1 : 0);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
paramWriter.writeInt8(-1);
|
|
182
|
-
}
|
|
183
|
-
// trustSelf
|
|
184
|
-
if (args.options.trustSelf === 'known') {
|
|
185
|
-
paramWriter.writeInt8(1);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
paramWriter.writeInt8(-1);
|
|
189
|
-
}
|
|
190
|
-
// knownTxids
|
|
191
|
-
if (args.options.knownTxids != null) {
|
|
192
|
-
paramWriter.writeVarIntNum(args.options.knownTxids.length);
|
|
193
|
-
for (const txid of args.options.knownTxids) {
|
|
194
|
-
const txidBytes = Utils.toArray(txid, 'hex');
|
|
195
|
-
paramWriter.write(txidBytes);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
paramWriter.writeVarIntNum(-1);
|
|
200
|
-
}
|
|
201
|
-
// returnTXIDOnly
|
|
202
|
-
if (typeof args.options.returnTXIDOnly === 'boolean') {
|
|
203
|
-
paramWriter.writeInt8(args.options.returnTXIDOnly ? 1 : 0);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
paramWriter.writeInt8(-1);
|
|
207
|
-
}
|
|
208
|
-
// noSend
|
|
209
|
-
if (typeof args.options.noSend === 'boolean') {
|
|
210
|
-
paramWriter.writeInt8(args.options.noSend ? 1 : 0);
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
paramWriter.writeInt8(-1);
|
|
214
|
-
}
|
|
215
|
-
// noSendChange
|
|
216
|
-
if (args.options.noSendChange != null) {
|
|
217
|
-
paramWriter.writeVarIntNum(args.options.noSendChange.length);
|
|
218
|
-
for (const outpoint of args.options.noSendChange) {
|
|
219
|
-
paramWriter.write(this.encodeOutpoint(outpoint));
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
paramWriter.writeVarIntNum(-1);
|
|
224
|
-
}
|
|
225
|
-
// sendWith
|
|
226
|
-
if (args.options.sendWith != null) {
|
|
227
|
-
paramWriter.writeVarIntNum(args.options.sendWith.length);
|
|
228
|
-
for (const txid of args.options.sendWith) {
|
|
229
|
-
const txidBytes = Utils.toArray(txid, 'hex');
|
|
230
|
-
paramWriter.write(txidBytes);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
paramWriter.writeVarIntNum(-1);
|
|
235
|
-
}
|
|
236
|
-
// randomizeOutputs
|
|
237
|
-
if (typeof args.options.randomizeOutputs === 'boolean') {
|
|
238
|
-
paramWriter.writeInt8(args.options.randomizeOutputs ? 1 : 0);
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
paramWriter.writeInt8(-1);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
paramWriter.writeInt8(0); // options not present
|
|
246
|
-
}
|
|
93
|
+
this.serializeCreateActionOptions(paramWriter, args.options);
|
|
247
94
|
// Transmit and parse response
|
|
248
95
|
const result = await this.transmit('createAction', originator, paramWriter.toArray());
|
|
96
|
+
return this.parseCreateActionResult(result);
|
|
97
|
+
}
|
|
98
|
+
parseCreateActionResult(result) {
|
|
249
99
|
const resultReader = new Utils.Reader(result);
|
|
250
100
|
const response = {};
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
response.
|
|
256
|
-
}
|
|
257
|
-
// Parse tx
|
|
258
|
-
const txFlag = resultReader.readInt8();
|
|
259
|
-
if (txFlag === 1) {
|
|
260
|
-
const txLength = resultReader.readVarIntNum();
|
|
261
|
-
response.tx = resultReader.read(txLength);
|
|
262
|
-
}
|
|
263
|
-
// Parse noSendChange
|
|
101
|
+
if (resultReader.readInt8() === 1) {
|
|
102
|
+
response.txid = Utils.toHex(resultReader.read(32));
|
|
103
|
+
}
|
|
104
|
+
if (resultReader.readInt8() === 1) {
|
|
105
|
+
response.tx = resultReader.read(resultReader.readVarIntNum());
|
|
106
|
+
}
|
|
264
107
|
const noSendChangeLength = resultReader.readVarIntNum();
|
|
265
108
|
if (noSendChangeLength >= 0) {
|
|
266
109
|
response.noSendChange = [];
|
|
267
110
|
for (let i = 0; i < noSendChangeLength; i++) {
|
|
268
|
-
|
|
269
|
-
response.noSendChange.push(outpoint);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
// Parse sendWithResults
|
|
273
|
-
const sendWithResultsLength = resultReader.readVarIntNum();
|
|
274
|
-
if (sendWithResultsLength >= 0) {
|
|
275
|
-
response.sendWithResults = [];
|
|
276
|
-
for (let i = 0; i < sendWithResultsLength; i++) {
|
|
277
|
-
const txidBytes = resultReader.read(32);
|
|
278
|
-
const txid = Utils.toHex(txidBytes);
|
|
279
|
-
const statusCode = resultReader.readInt8();
|
|
280
|
-
let status = 'unproven';
|
|
281
|
-
if (statusCode === 1)
|
|
282
|
-
status = 'unproven';
|
|
283
|
-
else if (statusCode === 2)
|
|
284
|
-
status = 'sending';
|
|
285
|
-
else if (statusCode === 3)
|
|
286
|
-
status = 'failed';
|
|
287
|
-
response.sendWithResults.push({ txid, status });
|
|
111
|
+
response.noSendChange.push(this.readOutpoint(resultReader));
|
|
288
112
|
}
|
|
289
113
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const tx = resultReader.read(
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
response.signableTransaction = {
|
|
298
|
-
tx,
|
|
299
|
-
reference: Utils.toBase64(referenceBytes)
|
|
300
|
-
};
|
|
114
|
+
const sendWithResults = this.readSendWithResults(resultReader);
|
|
115
|
+
if (sendWithResults != null)
|
|
116
|
+
response.sendWithResults = sendWithResults;
|
|
117
|
+
if (resultReader.readInt8() === 1) {
|
|
118
|
+
const tx = resultReader.read(resultReader.readVarIntNum());
|
|
119
|
+
const referenceBytes = resultReader.read(resultReader.readVarIntNum());
|
|
120
|
+
response.signableTransaction = { tx, reference: Utils.toBase64(referenceBytes) };
|
|
301
121
|
}
|
|
302
122
|
return response;
|
|
303
123
|
}
|
|
@@ -309,95 +129,30 @@ export default class WalletWireTransceiver {
|
|
|
309
129
|
for (const index of spendIndexes) {
|
|
310
130
|
paramWriter.writeVarIntNum(Number(index));
|
|
311
131
|
const spend = args.spends[Number(index)];
|
|
312
|
-
// unlockingScript
|
|
313
132
|
const unlockingScriptBytes = Utils.toArray(spend.unlockingScript, 'hex');
|
|
314
133
|
paramWriter.writeVarIntNum(unlockingScriptBytes.length);
|
|
315
134
|
paramWriter.write(unlockingScriptBytes);
|
|
316
|
-
|
|
317
|
-
if (typeof spend.sequenceNumber === 'number') {
|
|
318
|
-
paramWriter.writeVarIntNum(spend.sequenceNumber);
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
paramWriter.writeVarIntNum(-1);
|
|
322
|
-
}
|
|
135
|
+
this.writeOptionalVarInt(paramWriter, spend.sequenceNumber);
|
|
323
136
|
}
|
|
324
137
|
// Serialize reference
|
|
325
138
|
const referenceBytes = Utils.toArray(args.reference, 'base64');
|
|
326
139
|
paramWriter.writeVarIntNum(referenceBytes.length);
|
|
327
140
|
paramWriter.write(referenceBytes);
|
|
328
141
|
// Serialize options
|
|
329
|
-
|
|
330
|
-
paramWriter.writeInt8(1); // options present
|
|
331
|
-
// acceptDelayedBroadcast
|
|
332
|
-
if (typeof args.options.acceptDelayedBroadcast === 'boolean') {
|
|
333
|
-
paramWriter.writeInt8(args.options.acceptDelayedBroadcast ? 1 : 0);
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
paramWriter.writeInt8(-1);
|
|
337
|
-
}
|
|
338
|
-
// returnTXIDOnly
|
|
339
|
-
if (typeof args.options.returnTXIDOnly === 'boolean') {
|
|
340
|
-
paramWriter.writeInt8(args.options.returnTXIDOnly ? 1 : 0);
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
paramWriter.writeInt8(-1);
|
|
344
|
-
}
|
|
345
|
-
// noSend
|
|
346
|
-
if (typeof args.options.noSend === 'boolean') {
|
|
347
|
-
paramWriter.writeInt8(args.options.noSend ? 1 : 0);
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
paramWriter.writeInt8(-1);
|
|
351
|
-
}
|
|
352
|
-
// sendWith
|
|
353
|
-
if (args.options.sendWith != null) {
|
|
354
|
-
paramWriter.writeVarIntNum(args.options.sendWith.length);
|
|
355
|
-
for (const txid of args.options.sendWith) {
|
|
356
|
-
const txidBytes = Utils.toArray(txid, 'hex');
|
|
357
|
-
paramWriter.write(txidBytes);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
paramWriter.writeVarIntNum(-1);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
paramWriter.writeInt8(0); // options not present
|
|
366
|
-
}
|
|
142
|
+
this.serializeSignActionOptions(paramWriter, args.options);
|
|
367
143
|
// Transmit and parse response
|
|
368
144
|
const result = await this.transmit('signAction', originator, paramWriter.toArray());
|
|
369
145
|
const resultReader = new Utils.Reader(result);
|
|
370
146
|
const response = {};
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if (txidFlag === 1) {
|
|
374
|
-
const txidBytes = resultReader.read(32);
|
|
375
|
-
response.txid = Utils.toHex(txidBytes);
|
|
376
|
-
}
|
|
377
|
-
// Parse tx
|
|
378
|
-
const txFlag = resultReader.readInt8();
|
|
379
|
-
if (txFlag === 1) {
|
|
380
|
-
const txLength = resultReader.readVarIntNum();
|
|
381
|
-
response.tx = resultReader.read(txLength);
|
|
382
|
-
}
|
|
383
|
-
// Parse sendWithResults
|
|
384
|
-
const sendWithResultsLength = resultReader.readVarIntNum();
|
|
385
|
-
if (sendWithResultsLength >= 0) {
|
|
386
|
-
response.sendWithResults = [];
|
|
387
|
-
for (let i = 0; i < sendWithResultsLength; i++) {
|
|
388
|
-
const txidBytes = resultReader.read(32);
|
|
389
|
-
const txid = Utils.toHex(txidBytes);
|
|
390
|
-
const statusCode = resultReader.readInt8();
|
|
391
|
-
let status = 'unproven';
|
|
392
|
-
if (statusCode === 1)
|
|
393
|
-
status = 'unproven';
|
|
394
|
-
else if (statusCode === 2)
|
|
395
|
-
status = 'sending';
|
|
396
|
-
else if (statusCode === 3)
|
|
397
|
-
status = 'failed';
|
|
398
|
-
response.sendWithResults.push({ txid, status });
|
|
399
|
-
}
|
|
147
|
+
if (resultReader.readInt8() === 1) {
|
|
148
|
+
response.txid = Utils.toHex(resultReader.read(32));
|
|
400
149
|
}
|
|
150
|
+
if (resultReader.readInt8() === 1) {
|
|
151
|
+
response.tx = resultReader.read(resultReader.readVarIntNum());
|
|
152
|
+
}
|
|
153
|
+
const sendWithResults = this.readSendWithResults(resultReader);
|
|
154
|
+
if (sendWithResults != null)
|
|
155
|
+
response.sendWithResults = sendWithResults;
|
|
401
156
|
return response;
|
|
402
157
|
}
|
|
403
158
|
async abortAction(args, originator) {
|
|
@@ -406,223 +161,109 @@ export default class WalletWireTransceiver {
|
|
|
406
161
|
}
|
|
407
162
|
async listActions(args, originator) {
|
|
408
163
|
const paramWriter = new Utils.Writer();
|
|
409
|
-
// Serialize labels
|
|
164
|
+
// Serialize labels (always-present array, no -1 sentinel)
|
|
410
165
|
paramWriter.writeVarIntNum(args.labels.length);
|
|
411
166
|
for (const label of args.labels) {
|
|
412
|
-
|
|
413
|
-
paramWriter.writeVarIntNum(labelBytes.length);
|
|
414
|
-
paramWriter.write(labelBytes);
|
|
167
|
+
this.writeUTF8(paramWriter, label);
|
|
415
168
|
}
|
|
416
169
|
// Serialize labelQueryMode
|
|
417
|
-
if (args.labelQueryMode === 'any')
|
|
170
|
+
if (args.labelQueryMode === 'any')
|
|
418
171
|
paramWriter.writeInt8(1);
|
|
419
|
-
|
|
420
|
-
else if (args.labelQueryMode === 'all') {
|
|
172
|
+
else if (args.labelQueryMode === 'all')
|
|
421
173
|
paramWriter.writeInt8(2);
|
|
422
|
-
|
|
423
|
-
else {
|
|
174
|
+
else
|
|
424
175
|
paramWriter.writeInt8(-1);
|
|
425
|
-
}
|
|
426
176
|
// Serialize include options
|
|
427
|
-
const
|
|
177
|
+
for (const option of [
|
|
428
178
|
args.includeLabels,
|
|
429
179
|
args.includeInputs,
|
|
430
180
|
args.includeInputSourceLockingScripts,
|
|
431
181
|
args.includeInputUnlockingScripts,
|
|
432
182
|
args.includeOutputs,
|
|
433
183
|
args.includeOutputLockingScripts
|
|
434
|
-
]
|
|
435
|
-
|
|
436
|
-
if (typeof option === 'boolean') {
|
|
437
|
-
paramWriter.writeInt8(option ? 1 : 0);
|
|
438
|
-
}
|
|
439
|
-
else {
|
|
440
|
-
paramWriter.writeInt8(-1);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
// Serialize limit and offset
|
|
444
|
-
if (typeof args.limit === 'number') {
|
|
445
|
-
paramWriter.writeVarIntNum(args.limit);
|
|
446
|
-
}
|
|
447
|
-
else {
|
|
448
|
-
paramWriter.writeVarIntNum(-1);
|
|
184
|
+
]) {
|
|
185
|
+
this.writeOptionalBool(paramWriter, option);
|
|
449
186
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
else {
|
|
454
|
-
paramWriter.writeVarIntNum(-1);
|
|
455
|
-
}
|
|
456
|
-
// Serialize seekPermission
|
|
457
|
-
paramWriter.writeInt8(typeof args.seekPermission === 'boolean'
|
|
458
|
-
? args.seekPermission
|
|
459
|
-
? 1
|
|
460
|
-
: 0
|
|
461
|
-
: -1);
|
|
462
|
-
// Transmit and parse response
|
|
187
|
+
this.writeOptionalVarInt(paramWriter, args.limit);
|
|
188
|
+
this.writeOptionalVarInt(paramWriter, args.offset);
|
|
189
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
463
190
|
const result = await this.transmit('listActions', originator, paramWriter.toArray());
|
|
464
191
|
const resultReader = new Utils.Reader(result);
|
|
465
192
|
const totalActions = resultReader.readVarIntNum();
|
|
466
193
|
const actions = [];
|
|
467
194
|
for (let i = 0; i < totalActions; i++) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
case 6:
|
|
491
|
-
status = 'nosend';
|
|
492
|
-
break;
|
|
493
|
-
case 7:
|
|
494
|
-
status = 'nonfinal';
|
|
495
|
-
break;
|
|
496
|
-
case 8:
|
|
497
|
-
status = 'failed';
|
|
498
|
-
break;
|
|
499
|
-
default:
|
|
500
|
-
throw new Error(`Unknown status code: ${statusCode}`);
|
|
195
|
+
actions.push(this.parseAction(resultReader));
|
|
196
|
+
}
|
|
197
|
+
return { totalActions, actions };
|
|
198
|
+
}
|
|
199
|
+
parseActionStatus(code) {
|
|
200
|
+
const status = ACTION_STATUS_MAP[code];
|
|
201
|
+
if (status == null)
|
|
202
|
+
throw new Error(`Unknown status code: ${code}`);
|
|
203
|
+
return status;
|
|
204
|
+
}
|
|
205
|
+
parseAction(reader) {
|
|
206
|
+
const txid = Utils.toHex(reader.read(32));
|
|
207
|
+
const satoshis = reader.readVarIntNum();
|
|
208
|
+
const status = this.parseActionStatus(reader.readInt8());
|
|
209
|
+
const isOutgoing = reader.readInt8() === 1;
|
|
210
|
+
const description = Utils.toUTF8(reader.read(reader.readVarIntNum()));
|
|
211
|
+
const action = { txid, satoshis, status, isOutgoing, description, version: 0, lockTime: 0 };
|
|
212
|
+
const labelsLen = reader.readVarIntNum();
|
|
213
|
+
if (labelsLen >= 0) {
|
|
214
|
+
action.labels = [];
|
|
215
|
+
for (let j = 0; j < labelsLen; j++) {
|
|
216
|
+
action.labels.push(Utils.toUTF8(reader.read(reader.readVarIntNum())));
|
|
501
217
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
isOutgoing,
|
|
511
|
-
description,
|
|
512
|
-
version: 0,
|
|
513
|
-
lockTime: 0
|
|
514
|
-
};
|
|
515
|
-
// Parse labels
|
|
516
|
-
const labelsLength = resultReader.readVarIntNum();
|
|
517
|
-
if (labelsLength >= 0) {
|
|
518
|
-
action.labels = [];
|
|
519
|
-
for (let j = 0; j < labelsLength; j++) {
|
|
520
|
-
const labelLength = resultReader.readVarIntNum();
|
|
521
|
-
const labelBytes = resultReader.read(labelLength);
|
|
522
|
-
action.labels.push(Utils.toUTF8(labelBytes));
|
|
523
|
-
}
|
|
218
|
+
}
|
|
219
|
+
action.version = reader.readVarIntNum();
|
|
220
|
+
action.lockTime = reader.readVarIntNum();
|
|
221
|
+
const inputsLen = reader.readVarIntNum();
|
|
222
|
+
if (inputsLen >= 0) {
|
|
223
|
+
action.inputs = [];
|
|
224
|
+
for (let k = 0; k < inputsLen; k++) {
|
|
225
|
+
action.inputs.push(this.parseActionInput(reader));
|
|
524
226
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
action.inputs = [];
|
|
532
|
-
for (let k = 0; k < inputsLength; k++) {
|
|
533
|
-
const sourceOutpoint = this.readOutpoint(resultReader);
|
|
534
|
-
const sourceSatoshis = resultReader.readVarIntNum();
|
|
535
|
-
// sourceLockingScript
|
|
536
|
-
const sourceLockingScriptLength = resultReader.readVarIntNum();
|
|
537
|
-
let sourceLockingScript;
|
|
538
|
-
if (sourceLockingScriptLength >= 0) {
|
|
539
|
-
const sourceLockingScriptBytes = resultReader.read(sourceLockingScriptLength);
|
|
540
|
-
sourceLockingScript = Utils.toHex(sourceLockingScriptBytes);
|
|
541
|
-
}
|
|
542
|
-
// unlockingScript
|
|
543
|
-
const unlockingScriptLength = resultReader.readVarIntNum();
|
|
544
|
-
let unlockingScript;
|
|
545
|
-
if (unlockingScriptLength >= 0) {
|
|
546
|
-
const unlockingScriptBytes = resultReader.read(unlockingScriptLength);
|
|
547
|
-
unlockingScript = Utils.toHex(unlockingScriptBytes);
|
|
548
|
-
}
|
|
549
|
-
// inputDescription
|
|
550
|
-
const inputDescriptionLength = resultReader.readVarIntNum();
|
|
551
|
-
const inputDescriptionBytes = resultReader.read(inputDescriptionLength);
|
|
552
|
-
const inputDescription = Utils.toUTF8(inputDescriptionBytes);
|
|
553
|
-
// sequenceNumber
|
|
554
|
-
const sequenceNumber = resultReader.readVarIntNum();
|
|
555
|
-
action.inputs.push({
|
|
556
|
-
sourceOutpoint,
|
|
557
|
-
sourceSatoshis,
|
|
558
|
-
sourceLockingScript,
|
|
559
|
-
unlockingScript,
|
|
560
|
-
inputDescription,
|
|
561
|
-
sequenceNumber
|
|
562
|
-
});
|
|
563
|
-
}
|
|
227
|
+
}
|
|
228
|
+
const outputsLen = reader.readVarIntNum();
|
|
229
|
+
if (outputsLen >= 0) {
|
|
230
|
+
action.outputs = [];
|
|
231
|
+
for (let l = 0; l < outputsLen; l++) {
|
|
232
|
+
action.outputs.push(this.parseActionOutput(reader));
|
|
564
233
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
const tags = [];
|
|
594
|
-
if (tagsLength >= 0) {
|
|
595
|
-
for (let m = 0; m < tagsLength; m++) {
|
|
596
|
-
const tagLength = resultReader.readVarIntNum();
|
|
597
|
-
const tagBytes = resultReader.read(tagLength);
|
|
598
|
-
tags.push(Utils.toUTF8(tagBytes));
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
// customInstructions
|
|
602
|
-
const customInstructionsLength = resultReader.readVarIntNum();
|
|
603
|
-
let customInstructions;
|
|
604
|
-
if (customInstructionsLength >= 0) {
|
|
605
|
-
const customInstructionsBytes = resultReader.read(customInstructionsLength);
|
|
606
|
-
customInstructions = Utils.toUTF8(customInstructionsBytes);
|
|
607
|
-
}
|
|
608
|
-
action.outputs.push({
|
|
609
|
-
outputIndex,
|
|
610
|
-
satoshis,
|
|
611
|
-
lockingScript,
|
|
612
|
-
spendable,
|
|
613
|
-
outputDescription,
|
|
614
|
-
basket,
|
|
615
|
-
tags,
|
|
616
|
-
customInstructions
|
|
617
|
-
});
|
|
618
|
-
}
|
|
234
|
+
}
|
|
235
|
+
return action;
|
|
236
|
+
}
|
|
237
|
+
parseActionInput(reader) {
|
|
238
|
+
const sourceOutpoint = this.readOutpoint(reader);
|
|
239
|
+
const sourceSatoshis = reader.readVarIntNum();
|
|
240
|
+
const srcLockLen = reader.readVarIntNum();
|
|
241
|
+
const sourceLockingScript = srcLockLen >= 0 ? Utils.toHex(reader.read(srcLockLen)) : undefined;
|
|
242
|
+
const unlockLen = reader.readVarIntNum();
|
|
243
|
+
const unlockingScript = unlockLen >= 0 ? Utils.toHex(reader.read(unlockLen)) : undefined;
|
|
244
|
+
const inputDescription = Utils.toUTF8(reader.read(reader.readVarIntNum()));
|
|
245
|
+
const sequenceNumber = reader.readVarIntNum();
|
|
246
|
+
return { sourceOutpoint, sourceSatoshis, sourceLockingScript, unlockingScript, inputDescription, sequenceNumber };
|
|
247
|
+
}
|
|
248
|
+
parseActionOutput(reader) {
|
|
249
|
+
const outputIndex = reader.readVarIntNum();
|
|
250
|
+
const satoshis = reader.readVarIntNum();
|
|
251
|
+
const lockLen = reader.readVarIntNum();
|
|
252
|
+
const lockingScript = lockLen >= 0 ? Utils.toHex(reader.read(lockLen)) : undefined;
|
|
253
|
+
const spendable = reader.readInt8() === 1;
|
|
254
|
+
const outputDescription = Utils.toUTF8(reader.read(reader.readVarIntNum()));
|
|
255
|
+
const basketLen = reader.readVarIntNum();
|
|
256
|
+
const basket = basketLen >= 0 ? Utils.toUTF8(reader.read(basketLen)) : undefined;
|
|
257
|
+
const tagsLen = reader.readVarIntNum();
|
|
258
|
+
const tags = [];
|
|
259
|
+
if (tagsLen >= 0) {
|
|
260
|
+
for (let m = 0; m < tagsLen; m++) {
|
|
261
|
+
tags.push(Utils.toUTF8(reader.read(reader.readVarIntNum())));
|
|
619
262
|
}
|
|
620
|
-
actions.push(action);
|
|
621
263
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
};
|
|
264
|
+
const custLen = reader.readVarIntNum();
|
|
265
|
+
const customInstructions = custLen >= 0 ? Utils.toUTF8(reader.read(custLen)) : undefined;
|
|
266
|
+
return { outputIndex, satoshis, lockingScript, spendable, outputDescription, basket: basket, tags, customInstructions };
|
|
626
267
|
}
|
|
627
268
|
async internalizeAction(args, originator) {
|
|
628
269
|
const paramWriter = new Utils.Writer();
|
|
@@ -630,189 +271,119 @@ export default class WalletWireTransceiver {
|
|
|
630
271
|
paramWriter.write(args.tx);
|
|
631
272
|
paramWriter.writeVarIntNum(args.outputs.length);
|
|
632
273
|
for (const out of args.outputs) {
|
|
633
|
-
|
|
634
|
-
if (out.protocol === 'wallet payment') {
|
|
635
|
-
if (out.paymentRemittance == null) {
|
|
636
|
-
throw new Error('Payment remittance is required for wallet payment');
|
|
637
|
-
}
|
|
638
|
-
paramWriter.writeUInt8(1);
|
|
639
|
-
paramWriter.write(Utils.toArray(out.paymentRemittance.senderIdentityKey, 'hex'));
|
|
640
|
-
const derivationPrefixAsArray = Utils.toArray(out.paymentRemittance.derivationPrefix, 'base64');
|
|
641
|
-
paramWriter.writeVarIntNum(derivationPrefixAsArray.length);
|
|
642
|
-
paramWriter.write(derivationPrefixAsArray);
|
|
643
|
-
const derivationSuffixAsArray = Utils.toArray(out.paymentRemittance.derivationSuffix, 'base64');
|
|
644
|
-
paramWriter.writeVarIntNum(derivationSuffixAsArray.length);
|
|
645
|
-
paramWriter.write(derivationSuffixAsArray);
|
|
646
|
-
}
|
|
647
|
-
else {
|
|
648
|
-
paramWriter.writeUInt8(2);
|
|
649
|
-
const basketAsArray = Utils.toArray(out.insertionRemittance?.basket, 'utf8');
|
|
650
|
-
paramWriter.writeVarIntNum(basketAsArray.length);
|
|
651
|
-
paramWriter.write(basketAsArray);
|
|
652
|
-
if (typeof out.insertionRemittance?.customInstructions === 'string' && out.insertionRemittance.customInstructions !== '') {
|
|
653
|
-
const customInstructionsAsArray = Utils.toArray(out.insertionRemittance.customInstructions, 'utf8');
|
|
654
|
-
paramWriter.writeVarIntNum(customInstructionsAsArray.length);
|
|
655
|
-
paramWriter.write(customInstructionsAsArray);
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
paramWriter.writeVarIntNum(-1);
|
|
659
|
-
}
|
|
660
|
-
if (typeof out.insertionRemittance?.tags === 'object') {
|
|
661
|
-
paramWriter.writeVarIntNum(out.insertionRemittance.tags.length);
|
|
662
|
-
for (const tag of out.insertionRemittance.tags) {
|
|
663
|
-
const tagAsArray = Utils.toArray(tag, 'utf8');
|
|
664
|
-
paramWriter.writeVarIntNum(tagAsArray.length);
|
|
665
|
-
paramWriter.write(tagAsArray);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
else {
|
|
669
|
-
paramWriter.writeVarIntNum(0);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
if (typeof args.labels === 'object') {
|
|
674
|
-
paramWriter.writeVarIntNum(args.labels.length);
|
|
675
|
-
for (const l of args.labels) {
|
|
676
|
-
const labelAsArray = Utils.toArray(l, 'utf8');
|
|
677
|
-
paramWriter.writeVarIntNum(labelAsArray.length);
|
|
678
|
-
paramWriter.write(labelAsArray);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
else {
|
|
682
|
-
paramWriter.writeVarIntNum(-1);
|
|
274
|
+
this.serializeInternalizeOutput(paramWriter, out);
|
|
683
275
|
}
|
|
276
|
+
this.writeUTF8Array(paramWriter, typeof args.labels === 'object' ? args.labels : undefined);
|
|
684
277
|
const descriptionAsArray = Utils.toArray(args.description);
|
|
685
278
|
paramWriter.writeVarIntNum(descriptionAsArray.length);
|
|
686
279
|
paramWriter.write(descriptionAsArray);
|
|
687
|
-
|
|
688
|
-
paramWriter.writeInt8(typeof args.seekPermission === 'boolean'
|
|
689
|
-
? args.seekPermission
|
|
690
|
-
? 1
|
|
691
|
-
: 0
|
|
692
|
-
: -1);
|
|
280
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
693
281
|
await this.transmit('internalizeAction', originator, paramWriter.toArray());
|
|
694
282
|
return { accepted: true };
|
|
695
283
|
}
|
|
284
|
+
serializeInternalizeOutput(writer, out) {
|
|
285
|
+
writer.writeVarIntNum(out.outputIndex);
|
|
286
|
+
if (out.protocol === 'wallet payment') {
|
|
287
|
+
if (out.paymentRemittance == null) {
|
|
288
|
+
throw new Error('Payment remittance is required for wallet payment');
|
|
289
|
+
}
|
|
290
|
+
writer.writeUInt8(1);
|
|
291
|
+
writer.write(Utils.toArray(out.paymentRemittance.senderIdentityKey, 'hex'));
|
|
292
|
+
const prefix = Utils.toArray(out.paymentRemittance.derivationPrefix, 'base64');
|
|
293
|
+
writer.writeVarIntNum(prefix.length);
|
|
294
|
+
writer.write(prefix);
|
|
295
|
+
const suffix = Utils.toArray(out.paymentRemittance.derivationSuffix, 'base64');
|
|
296
|
+
writer.writeVarIntNum(suffix.length);
|
|
297
|
+
writer.write(suffix);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
writer.writeUInt8(2);
|
|
301
|
+
const basket = Utils.toArray(out.insertionRemittance?.basket, 'utf8');
|
|
302
|
+
writer.writeVarIntNum(basket.length);
|
|
303
|
+
writer.write(basket);
|
|
304
|
+
this.writeOptionalUTF8(writer, out.insertionRemittance?.customInstructions);
|
|
305
|
+
const tags = out.insertionRemittance?.tags;
|
|
306
|
+
if (typeof tags === 'object') {
|
|
307
|
+
writer.writeVarIntNum(tags.length);
|
|
308
|
+
for (const tag of tags) {
|
|
309
|
+
const t = Utils.toArray(tag, 'utf8');
|
|
310
|
+
writer.writeVarIntNum(t.length);
|
|
311
|
+
writer.write(t);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
writer.writeVarIntNum(0);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
696
319
|
async listOutputs(args, originator) {
|
|
697
320
|
const paramWriter = new Utils.Writer();
|
|
698
|
-
|
|
699
|
-
paramWriter.writeVarIntNum(basketAsArray.length);
|
|
700
|
-
paramWriter.write(basketAsArray);
|
|
321
|
+
this.writeUTF8(paramWriter, args.basket);
|
|
701
322
|
if (typeof args.tags === 'object') {
|
|
702
323
|
paramWriter.writeVarIntNum(args.tags.length);
|
|
703
324
|
for (const tag of args.tags) {
|
|
704
|
-
|
|
705
|
-
paramWriter.writeVarIntNum(tagAsArray.length);
|
|
706
|
-
paramWriter.write(tagAsArray);
|
|
325
|
+
this.writeUTF8(paramWriter, tag);
|
|
707
326
|
}
|
|
708
327
|
}
|
|
709
328
|
else {
|
|
710
329
|
paramWriter.writeVarIntNum(0);
|
|
711
330
|
}
|
|
712
|
-
if (args.tagQueryMode === 'all')
|
|
331
|
+
if (args.tagQueryMode === 'all')
|
|
713
332
|
paramWriter.writeInt8(1);
|
|
714
|
-
|
|
715
|
-
else if (args.tagQueryMode === 'any') {
|
|
333
|
+
else if (args.tagQueryMode === 'any')
|
|
716
334
|
paramWriter.writeInt8(2);
|
|
717
|
-
|
|
718
|
-
else {
|
|
335
|
+
else
|
|
719
336
|
paramWriter.writeInt8(-1);
|
|
720
|
-
|
|
721
|
-
if (args.include === 'locking scripts') {
|
|
337
|
+
if (args.include === 'locking scripts')
|
|
722
338
|
paramWriter.writeInt8(1);
|
|
723
|
-
|
|
724
|
-
else if (args.include === 'entire transactions') {
|
|
339
|
+
else if (args.include === 'entire transactions')
|
|
725
340
|
paramWriter.writeInt8(2);
|
|
726
|
-
|
|
727
|
-
else {
|
|
728
|
-
paramWriter.writeInt8(-1);
|
|
729
|
-
}
|
|
730
|
-
if (typeof args.includeCustomInstructions === 'boolean') {
|
|
731
|
-
paramWriter.writeInt8(args.includeCustomInstructions ? 1 : 0);
|
|
732
|
-
}
|
|
733
|
-
else {
|
|
341
|
+
else
|
|
734
342
|
paramWriter.writeInt8(-1);
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
}
|
|
742
|
-
if (typeof args.includeLabels === 'boolean') {
|
|
743
|
-
paramWriter.writeInt8(args.includeLabels ? 1 : 0);
|
|
744
|
-
}
|
|
745
|
-
else {
|
|
746
|
-
paramWriter.writeInt8(-1);
|
|
747
|
-
}
|
|
748
|
-
if (typeof args.limit === 'number') {
|
|
749
|
-
paramWriter.writeVarIntNum(args.limit);
|
|
750
|
-
}
|
|
751
|
-
else {
|
|
752
|
-
paramWriter.writeVarIntNum(-1);
|
|
753
|
-
}
|
|
754
|
-
if (typeof args.offset === 'number') {
|
|
755
|
-
paramWriter.writeVarIntNum(args.offset);
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
paramWriter.writeVarIntNum(-1);
|
|
759
|
-
}
|
|
760
|
-
// Serialize seekPermission
|
|
761
|
-
paramWriter.writeInt8(typeof args.seekPermission === 'boolean'
|
|
762
|
-
? args.seekPermission
|
|
763
|
-
? 1
|
|
764
|
-
: 0
|
|
765
|
-
: -1);
|
|
343
|
+
this.writeOptionalBool(paramWriter, args.includeCustomInstructions);
|
|
344
|
+
this.writeOptionalBool(paramWriter, args.includeTags);
|
|
345
|
+
this.writeOptionalBool(paramWriter, args.includeLabels);
|
|
346
|
+
this.writeOptionalVarInt(paramWriter, args.limit);
|
|
347
|
+
this.writeOptionalVarInt(paramWriter, args.offset);
|
|
348
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
766
349
|
const result = await this.transmit('listOutputs', originator, paramWriter.toArray());
|
|
767
350
|
const resultReader = new Utils.Reader(result);
|
|
768
351
|
const totalOutputs = resultReader.readVarIntNum();
|
|
769
352
|
const beefLength = resultReader.readVarIntNum();
|
|
770
|
-
|
|
771
|
-
if (beefLength >= 0) {
|
|
772
|
-
BEEF = resultReader.read(beefLength);
|
|
773
|
-
}
|
|
353
|
+
const BEEF = beefLength >= 0 ? resultReader.read(beefLength) : undefined;
|
|
774
354
|
const outputs = [];
|
|
775
355
|
for (let i = 0; i < totalOutputs; i++) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
const tagLength = resultReader.readVarIntNum();
|
|
796
|
-
tags.push(Utils.toUTF8(resultReader.read(tagLength)));
|
|
797
|
-
}
|
|
798
|
-
output.tags = tags;
|
|
356
|
+
outputs.push(this.parseListOutputEntry(resultReader));
|
|
357
|
+
}
|
|
358
|
+
return { totalOutputs, BEEF, outputs };
|
|
359
|
+
}
|
|
360
|
+
parseListOutputEntry(reader) {
|
|
361
|
+
const outpoint = this.readOutpoint(reader);
|
|
362
|
+
const satoshis = reader.readVarIntNum();
|
|
363
|
+
const output = { spendable: true, outpoint, satoshis };
|
|
364
|
+
const scriptLen = reader.readVarIntNum();
|
|
365
|
+
if (scriptLen >= 0)
|
|
366
|
+
output.lockingScript = Utils.toHex(reader.read(scriptLen));
|
|
367
|
+
const custLen = reader.readVarIntNum();
|
|
368
|
+
if (custLen >= 0)
|
|
369
|
+
output.customInstructions = Utils.toUTF8(reader.read(custLen));
|
|
370
|
+
const tagsLen = reader.readVarIntNum();
|
|
371
|
+
if (tagsLen !== -1) {
|
|
372
|
+
const tags = [];
|
|
373
|
+
for (let i = 0; i < tagsLen; i++) {
|
|
374
|
+
tags.push(Utils.toUTF8(reader.read(reader.readVarIntNum())));
|
|
799
375
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
output.labels = labels;
|
|
376
|
+
output.tags = tags;
|
|
377
|
+
}
|
|
378
|
+
const labelsLen = reader.readVarIntNum();
|
|
379
|
+
if (labelsLen !== -1) {
|
|
380
|
+
const labels = [];
|
|
381
|
+
for (let i = 0; i < labelsLen; i++) {
|
|
382
|
+
labels.push(Utils.toUTF8(reader.read(reader.readVarIntNum())));
|
|
808
383
|
}
|
|
809
|
-
|
|
384
|
+
output.labels = labels;
|
|
810
385
|
}
|
|
811
|
-
return
|
|
812
|
-
totalOutputs,
|
|
813
|
-
BEEF,
|
|
814
|
-
outputs
|
|
815
|
-
};
|
|
386
|
+
return output;
|
|
816
387
|
}
|
|
817
388
|
async relinquishOutput(args, originator) {
|
|
818
389
|
const paramWriter = new Utils.Writer();
|
|
@@ -838,8 +409,13 @@ export default class WalletWireTransceiver {
|
|
|
838
409
|
async getPublicKey(args, originator) {
|
|
839
410
|
const paramWriter = new Utils.Writer();
|
|
840
411
|
paramWriter.writeUInt8(args.identityKey ? 1 : 0);
|
|
841
|
-
if (
|
|
842
|
-
paramWriter.write(this.
|
|
412
|
+
if (args.identityKey) {
|
|
413
|
+
paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
args.protocolID ??= [SecurityLevels.Silent, 'default'];
|
|
417
|
+
args.keyID ??= '';
|
|
418
|
+
paramWriter.write(this.encodeKeyRelatedParams(args.protocolID, args.keyID, args.counterparty, args.privileged, args.privilegedReason));
|
|
843
419
|
if (typeof args.forSelf === 'boolean') {
|
|
844
420
|
paramWriter.writeInt8(args.forSelf ? 1 : 0);
|
|
845
421
|
}
|
|
@@ -847,15 +423,8 @@ export default class WalletWireTransceiver {
|
|
|
847
423
|
paramWriter.writeInt8(-1);
|
|
848
424
|
}
|
|
849
425
|
}
|
|
850
|
-
else {
|
|
851
|
-
paramWriter.write(this.encodePrivilegedParams(args.privileged, args.privilegedReason));
|
|
852
|
-
}
|
|
853
426
|
// Serialize seekPermission
|
|
854
|
-
|
|
855
|
-
? args.seekPermission
|
|
856
|
-
? 1
|
|
857
|
-
: 0
|
|
858
|
-
: -1);
|
|
427
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
859
428
|
const result = await this.transmit('getPublicKey', originator, paramWriter.toArray());
|
|
860
429
|
return {
|
|
861
430
|
publicKey: Utils.toHex(result)
|
|
@@ -922,11 +491,7 @@ export default class WalletWireTransceiver {
|
|
|
922
491
|
paramWriter.writeVarIntNum(args.plaintext.length);
|
|
923
492
|
paramWriter.write(args.plaintext);
|
|
924
493
|
// Serialize seekPermission
|
|
925
|
-
|
|
926
|
-
? args.seekPermission
|
|
927
|
-
? 1
|
|
928
|
-
: 0
|
|
929
|
-
: -1);
|
|
494
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
930
495
|
return {
|
|
931
496
|
ciphertext: await this.transmit('encrypt', originator, paramWriter.toArray())
|
|
932
497
|
};
|
|
@@ -937,11 +502,7 @@ export default class WalletWireTransceiver {
|
|
|
937
502
|
paramWriter.writeVarIntNum(args.ciphertext.length);
|
|
938
503
|
paramWriter.write(args.ciphertext);
|
|
939
504
|
// Serialize seekPermission
|
|
940
|
-
|
|
941
|
-
? args.seekPermission
|
|
942
|
-
? 1
|
|
943
|
-
: 0
|
|
944
|
-
: -1);
|
|
505
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
945
506
|
return {
|
|
946
507
|
plaintext: await this.transmit('decrypt', originator, paramWriter.toArray())
|
|
947
508
|
};
|
|
@@ -952,11 +513,7 @@ export default class WalletWireTransceiver {
|
|
|
952
513
|
paramWriter.writeVarIntNum(args.data.length);
|
|
953
514
|
paramWriter.write(args.data);
|
|
954
515
|
// Serialize seekPermission
|
|
955
|
-
|
|
956
|
-
? args.seekPermission
|
|
957
|
-
? 1
|
|
958
|
-
: 0
|
|
959
|
-
: -1);
|
|
516
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
960
517
|
return {
|
|
961
518
|
hmac: await this.transmit('createHmac', originator, paramWriter.toArray())
|
|
962
519
|
};
|
|
@@ -968,11 +525,7 @@ export default class WalletWireTransceiver {
|
|
|
968
525
|
paramWriter.writeVarIntNum(args.data.length);
|
|
969
526
|
paramWriter.write(args.data);
|
|
970
527
|
// Serialize seekPermission
|
|
971
|
-
|
|
972
|
-
? args.seekPermission
|
|
973
|
-
? 1
|
|
974
|
-
: 0
|
|
975
|
-
: -1);
|
|
528
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
976
529
|
await this.transmit('verifyHmac', originator, paramWriter.toArray());
|
|
977
530
|
return { valid: true };
|
|
978
531
|
}
|
|
@@ -985,15 +538,12 @@ export default class WalletWireTransceiver {
|
|
|
985
538
|
paramWriter.write(args.data);
|
|
986
539
|
}
|
|
987
540
|
else {
|
|
541
|
+
args.hashToDirectlySign ??= [];
|
|
988
542
|
paramWriter.writeUInt8(2);
|
|
989
|
-
paramWriter.write(args.hashToDirectlySign
|
|
543
|
+
paramWriter.write(args.hashToDirectlySign);
|
|
990
544
|
}
|
|
991
545
|
// Serialize seekPermission
|
|
992
|
-
|
|
993
|
-
? args.seekPermission
|
|
994
|
-
? 1
|
|
995
|
-
: 0
|
|
996
|
-
: -1);
|
|
546
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
997
547
|
return {
|
|
998
548
|
signature: await this.transmit('createSignature', originator, paramWriter.toArray())
|
|
999
549
|
};
|
|
@@ -1019,14 +569,148 @@ export default class WalletWireTransceiver {
|
|
|
1019
569
|
paramWriter.write(args.hashToDirectlyVerify ?? []);
|
|
1020
570
|
}
|
|
1021
571
|
// Serialize seekPermission
|
|
1022
|
-
|
|
1023
|
-
? args.seekPermission
|
|
1024
|
-
? 1
|
|
1025
|
-
: 0
|
|
1026
|
-
: -1);
|
|
572
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
1027
573
|
await this.transmit('verifySignature', originator, paramWriter.toArray());
|
|
1028
574
|
return { valid: true };
|
|
1029
575
|
}
|
|
576
|
+
/** Writes an optional boolean as Int8: 1/0 if present, -1 if absent. */
|
|
577
|
+
writeOptionalBool(writer, val) {
|
|
578
|
+
if (typeof val === 'boolean') {
|
|
579
|
+
writer.writeInt8(val ? 1 : 0);
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
writer.writeInt8(-1);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
/** Writes an optional number as VarInt: the value if present, -1 if absent. */
|
|
586
|
+
writeOptionalVarInt(writer, val) {
|
|
587
|
+
if (typeof val === 'number') {
|
|
588
|
+
writer.writeVarIntNum(val);
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
writer.writeVarIntNum(-1);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
/** Writes a UTF-8 string as (VarInt length, bytes). */
|
|
595
|
+
writeUTF8(writer, val) {
|
|
596
|
+
const bytes = Utils.toArray(val ?? '', 'utf8');
|
|
597
|
+
writer.writeVarIntNum(bytes.length);
|
|
598
|
+
writer.write(bytes);
|
|
599
|
+
}
|
|
600
|
+
/** Writes an optional UTF-8 string: (VarInt length, bytes) if non-empty, -1 if absent/empty. */
|
|
601
|
+
writeOptionalUTF8(writer, val) {
|
|
602
|
+
if (val != null && val !== '') {
|
|
603
|
+
const bytes = Utils.toArray(val, 'utf8');
|
|
604
|
+
writer.writeVarIntNum(bytes.length);
|
|
605
|
+
writer.write(bytes);
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
writer.writeVarIntNum(-1);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
/** Writes an array of UTF-8 strings as (VarInt count, ...items). -1 if null. */
|
|
612
|
+
writeUTF8Array(writer, arr) {
|
|
613
|
+
if (arr == null) {
|
|
614
|
+
writer.writeVarIntNum(-1);
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
writer.writeVarIntNum(arr.length);
|
|
618
|
+
for (const item of arr) {
|
|
619
|
+
const bytes = Utils.toArray(item, 'utf8');
|
|
620
|
+
writer.writeVarIntNum(bytes.length);
|
|
621
|
+
writer.write(bytes);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
/** Writes an array of hex-encoded txids (each 32 bytes) as (VarInt count, ...items). -1 if null. */
|
|
626
|
+
writeTxidArray(writer, arr) {
|
|
627
|
+
if (arr == null) {
|
|
628
|
+
writer.writeVarIntNum(-1);
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
writer.writeVarIntNum(arr.length);
|
|
632
|
+
for (const txid of arr) {
|
|
633
|
+
writer.write(Utils.toArray(txid, 'hex'));
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
/** Reads a list of SendWithResults entries from a binary reader. */
|
|
638
|
+
readSendWithResults(reader) {
|
|
639
|
+
const len = reader.readVarIntNum();
|
|
640
|
+
if (len < 0)
|
|
641
|
+
return undefined;
|
|
642
|
+
const results = [];
|
|
643
|
+
for (let i = 0; i < len; i++) {
|
|
644
|
+
const txid = Utils.toHex(reader.read(32));
|
|
645
|
+
const code = reader.readInt8();
|
|
646
|
+
const status = code === 2 ? 'sending' : code === 3 ? 'failed' : 'unproven';
|
|
647
|
+
results.push({ txid, status });
|
|
648
|
+
}
|
|
649
|
+
return results;
|
|
650
|
+
}
|
|
651
|
+
/** Serializes a single createAction input to the writer. */
|
|
652
|
+
serializeCreateActionInput(writer, input) {
|
|
653
|
+
writer.write(this.encodeOutpoint(input.outpoint));
|
|
654
|
+
if (input.unlockingScript != null && input.unlockingScript !== '') {
|
|
655
|
+
const bytes = Utils.toArray(input.unlockingScript, 'hex');
|
|
656
|
+
writer.writeVarIntNum(bytes.length);
|
|
657
|
+
writer.write(bytes);
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
writer.writeVarIntNum(-1);
|
|
661
|
+
writer.writeVarIntNum(input.unlockingScriptLength ?? 0);
|
|
662
|
+
}
|
|
663
|
+
this.writeUTF8(writer, input.inputDescription);
|
|
664
|
+
this.writeOptionalVarInt(writer, input.sequenceNumber);
|
|
665
|
+
}
|
|
666
|
+
/** Serializes a single createAction output to the writer. */
|
|
667
|
+
serializeCreateActionOutput(writer, output) {
|
|
668
|
+
const lockingBytes = Utils.toArray(output.lockingScript, 'hex');
|
|
669
|
+
writer.writeVarIntNum(lockingBytes.length);
|
|
670
|
+
writer.write(lockingBytes);
|
|
671
|
+
writer.writeVarIntNum(output.satoshis);
|
|
672
|
+
this.writeUTF8(writer, output.outputDescription);
|
|
673
|
+
this.writeOptionalUTF8(writer, output.basket);
|
|
674
|
+
this.writeOptionalUTF8(writer, output.customInstructions);
|
|
675
|
+
this.writeUTF8Array(writer, output.tags);
|
|
676
|
+
}
|
|
677
|
+
/** Serializes createAction options to the writer (Int8 presence byte + fields). */
|
|
678
|
+
serializeCreateActionOptions(writer, options) {
|
|
679
|
+
if (options == null) {
|
|
680
|
+
writer.writeInt8(0);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
writer.writeInt8(1);
|
|
684
|
+
this.writeOptionalBool(writer, options.signAndProcess);
|
|
685
|
+
this.writeOptionalBool(writer, options.acceptDelayedBroadcast);
|
|
686
|
+
writer.writeInt8(options.trustSelf === 'known' ? 1 : -1);
|
|
687
|
+
this.writeTxidArray(writer, options.knownTxids);
|
|
688
|
+
this.writeOptionalBool(writer, options.returnTXIDOnly);
|
|
689
|
+
this.writeOptionalBool(writer, options.noSend);
|
|
690
|
+
if (options.noSendChange == null) {
|
|
691
|
+
writer.writeVarIntNum(-1);
|
|
692
|
+
}
|
|
693
|
+
else {
|
|
694
|
+
writer.writeVarIntNum(options.noSendChange.length);
|
|
695
|
+
for (const outpoint of options.noSendChange) {
|
|
696
|
+
writer.write(this.encodeOutpoint(outpoint));
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
this.writeTxidArray(writer, options.sendWith);
|
|
700
|
+
this.writeOptionalBool(writer, options.randomizeOutputs);
|
|
701
|
+
}
|
|
702
|
+
/** Serializes signAction options to the writer (Int8 presence byte + fields). */
|
|
703
|
+
serializeSignActionOptions(writer, options) {
|
|
704
|
+
if (options == null) {
|
|
705
|
+
writer.writeInt8(0);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
writer.writeInt8(1);
|
|
709
|
+
this.writeOptionalBool(writer, options.acceptDelayedBroadcast);
|
|
710
|
+
this.writeOptionalBool(writer, options.returnTXIDOnly);
|
|
711
|
+
this.writeOptionalBool(writer, options.noSend);
|
|
712
|
+
this.writeTxidArray(writer, options.sendWith);
|
|
713
|
+
}
|
|
1030
714
|
encodeKeyRelatedParams(protocolID, keyID, counterparty, privileged, privilegedReason) {
|
|
1031
715
|
const paramWriter = new Utils.Writer();
|
|
1032
716
|
paramWriter.writeUInt8(protocolID[0]);
|
|
@@ -1073,17 +757,17 @@ export default class WalletWireTransceiver {
|
|
|
1073
757
|
const signatureAsArray = Utils.toArray(args.signature, 'hex');
|
|
1074
758
|
paramWriter.writeVarIntNum(signatureAsArray.length);
|
|
1075
759
|
paramWriter.write(signatureAsArray);
|
|
1076
|
-
const keyringRevealerAsArray = args.keyringRevealer
|
|
1077
|
-
?
|
|
1078
|
-
:
|
|
760
|
+
const keyringRevealerAsArray = args.keyringRevealer === 'certifier'
|
|
761
|
+
? [11]
|
|
762
|
+
: Utils.toArray(args.keyringRevealer, 'hex');
|
|
1079
763
|
paramWriter.write(keyringRevealerAsArray);
|
|
1080
764
|
const keyringKeys = Object.keys(args.keyringForSubject ?? {});
|
|
1081
765
|
paramWriter.writeVarIntNum(keyringKeys.length);
|
|
1082
|
-
for (
|
|
1083
|
-
const keyringKeysAsArray = Utils.toArray(
|
|
766
|
+
for (const key of keyringKeys) {
|
|
767
|
+
const keyringKeysAsArray = Utils.toArray(key, 'utf8');
|
|
1084
768
|
paramWriter.writeVarIntNum(keyringKeysAsArray.length);
|
|
1085
769
|
paramWriter.write(keyringKeysAsArray);
|
|
1086
|
-
const keyringForSubjectAsArray = Utils.toArray(args.keyringForSubject?.[
|
|
770
|
+
const keyringForSubjectAsArray = Utils.toArray(args.keyringForSubject?.[key], 'base64');
|
|
1087
771
|
paramWriter.writeVarIntNum(keyringForSubjectAsArray.length);
|
|
1088
772
|
paramWriter.write(keyringForSubjectAsArray);
|
|
1089
773
|
}
|
|
@@ -1121,12 +805,12 @@ export default class WalletWireTransceiver {
|
|
|
1121
805
|
async listCertificates(args, originator) {
|
|
1122
806
|
const paramWriter = new Utils.Writer();
|
|
1123
807
|
paramWriter.writeVarIntNum(args.certifiers.length);
|
|
1124
|
-
for (
|
|
1125
|
-
paramWriter.write(Utils.toArray(
|
|
808
|
+
for (const certifier of args.certifiers) {
|
|
809
|
+
paramWriter.write(Utils.toArray(certifier, 'hex'));
|
|
1126
810
|
}
|
|
1127
811
|
paramWriter.writeVarIntNum(args.types.length);
|
|
1128
|
-
for (
|
|
1129
|
-
paramWriter.write(Utils.toArray(
|
|
812
|
+
for (const type of args.types) {
|
|
813
|
+
paramWriter.write(Utils.toArray(type, 'base64'));
|
|
1130
814
|
}
|
|
1131
815
|
if (typeof args.limit === 'number') {
|
|
1132
816
|
paramWriter.writeVarIntNum(args.limit);
|
|
@@ -1160,7 +844,7 @@ export default class WalletWireTransceiver {
|
|
|
1160
844
|
}
|
|
1161
845
|
}
|
|
1162
846
|
const verifierLength = resultReader.readVarIntNum();
|
|
1163
|
-
let verifier
|
|
847
|
+
let verifier;
|
|
1164
848
|
if (verifierLength > 0) {
|
|
1165
849
|
verifier = Utils.toUTF8(resultReader.read(verifierLength));
|
|
1166
850
|
}
|
|
@@ -1168,7 +852,7 @@ export default class WalletWireTransceiver {
|
|
|
1168
852
|
...cert,
|
|
1169
853
|
signature: cert.signature,
|
|
1170
854
|
keyring: keyringForVerifier,
|
|
1171
|
-
verifier
|
|
855
|
+
verifier
|
|
1172
856
|
});
|
|
1173
857
|
}
|
|
1174
858
|
return {
|
|
@@ -1294,11 +978,7 @@ export default class WalletWireTransceiver {
|
|
|
1294
978
|
paramWriter.writeVarIntNum(-1);
|
|
1295
979
|
}
|
|
1296
980
|
// Serialize seekPermission
|
|
1297
|
-
|
|
1298
|
-
? args.seekPermission
|
|
1299
|
-
? 1
|
|
1300
|
-
: 0
|
|
1301
|
-
: -1);
|
|
981
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
1302
982
|
const result = await this.transmit('discoverByIdentityKey', originator, paramWriter.toArray());
|
|
1303
983
|
return this.parseDiscoveryResult(result);
|
|
1304
984
|
}
|
|
@@ -1306,11 +986,11 @@ export default class WalletWireTransceiver {
|
|
|
1306
986
|
const paramWriter = new Utils.Writer();
|
|
1307
987
|
const attributeKeys = Object.keys(args.attributes);
|
|
1308
988
|
paramWriter.writeVarIntNum(attributeKeys.length);
|
|
1309
|
-
for (
|
|
1310
|
-
paramWriter.writeVarIntNum(
|
|
1311
|
-
paramWriter.write(Utils.toArray(
|
|
1312
|
-
paramWriter.writeVarIntNum(args.attributes[
|
|
1313
|
-
paramWriter.write(Utils.toArray(args.attributes[
|
|
989
|
+
for (const attrKey of attributeKeys) {
|
|
990
|
+
paramWriter.writeVarIntNum(attrKey.length);
|
|
991
|
+
paramWriter.write(Utils.toArray(attrKey, 'utf8'));
|
|
992
|
+
paramWriter.writeVarIntNum(args.attributes[attrKey].length);
|
|
993
|
+
paramWriter.write(Utils.toArray(args.attributes[attrKey], 'utf8'));
|
|
1314
994
|
}
|
|
1315
995
|
if (typeof args.limit === 'number') {
|
|
1316
996
|
paramWriter.writeVarIntNum(args.limit);
|
|
@@ -1325,11 +1005,7 @@ export default class WalletWireTransceiver {
|
|
|
1325
1005
|
paramWriter.writeVarIntNum(-1);
|
|
1326
1006
|
}
|
|
1327
1007
|
// Serialize seekPermission
|
|
1328
|
-
|
|
1329
|
-
? args.seekPermission
|
|
1330
|
-
? 1
|
|
1331
|
-
: 0
|
|
1332
|
-
: -1);
|
|
1008
|
+
this.writeOptionalBool(paramWriter, args.seekPermission);
|
|
1333
1009
|
const result = await this.transmit('discoverByAttributes', originator, paramWriter.toArray());
|
|
1334
1010
|
return this.parseDiscoveryResult(result);
|
|
1335
1011
|
}
|