diff --git a/src/components/Network.vue b/src/components/Network.vue index fbe019c2..99505503 100644 --- a/src/components/Network.vue +++ b/src/components/Network.vue @@ -23,7 +23,7 @@ class Network extends Vue { fee = 0, validityStartHeight, flags = 0 /* Nimiq.Transaction.Flag.NONE */, - data, + recipientData, signerPubKey, signature, proofPrefix = new Uint8Array(0), @@ -37,7 +37,7 @@ class Network extends Vue { fee?: number, validityStartHeight: number, flags?: number, - data?: Uint8Array, + recipientData?: Uint8Array, signerPubKey: Nimiq.PublicKey | Uint8Array, signature?: Nimiq.Signature | Uint8Array, proofPrefix?: Uint8Array, @@ -48,27 +48,26 @@ class Network extends Vue { if (signature && !(signature instanceof Nimiq.Signature)) signature = Nimiq.Signature.deserialize(signature); if ( - (data && data.length > 0) + (recipientData && recipientData.length > 0) || senderType !== Nimiq.AccountType.Basic || recipientType !== Nimiq.AccountType.Basic || flags !== 0 /* Nimiq.Transaction.Flag.NONE */ ) { let proof: Nimiq.SerialBuffer | undefined; if (signature) { - // 32 publicKey + 1 empty merkle path + 64 signature - proof = new Nimiq.SerialBuffer(proofPrefix.length + 32 + 1 + 64); + // 1 type + 32 publicKey + 1 empty merkle path + 64 signature + proof = new Nimiq.SerialBuffer(proofPrefix.length + 1 + 32 + 1 + 64); proof.write(proofPrefix); proof.write(Nimiq.SignatureProof.singleSig(signerPubKey, signature).serialize()); } const tx = new Nimiq.Transaction( sender, - // @ts-ignore Staking type not yet supported senderType, senderData, recipient, recipientType, - data || new Uint8Array(0), + recipientData || new Uint8Array(0), BigInt(value), BigInt(fee), flags, diff --git a/src/lib/Cashlink.ts b/src/lib/Cashlink.ts index 40a8ece5..e99b6ae8 100644 --- a/src/lib/Cashlink.ts +++ b/src/lib/Cashlink.ts @@ -90,7 +90,8 @@ class Cashlink { try { str = str.replace(/~/g, '').replace(/=*$/, (match) => new Array(match.length).fill('.').join('')); const buf = Nimiq.BufferUtils.fromBase64Url(str); - const keyPair = Nimiq.KeyPair.derive(Nimiq.PrivateKey.deserialize(buf)); + const privateKeyBytes = buf.read(Nimiq.PrivateKey.SIZE); + const keyPair = Nimiq.KeyPair.derive(Nimiq.PrivateKey.deserialize(privateKeyBytes)); const value = buf.readUint64(); let message: string; if (buf.readPos === buf.byteLength) { @@ -304,7 +305,7 @@ class Cashlink { recipient: Nimiq.Address, value: number, fee: number, - data: Uint8Array, + recipientData: Uint8Array, cashlinkMessage: string, } { return { @@ -312,7 +313,7 @@ class Cashlink { recipient: this.address, value: this.value, fee: this.fee, - data: CashlinkExtraData.FUNDING, + recipientData: CashlinkExtraData.FUNDING, cashlinkMessage: this.message, }; } diff --git a/src/views/RefundSwapSuccess.vue b/src/views/RefundSwapSuccess.vue index a1dfd889..468f8f94 100644 --- a/src/views/RefundSwapSuccess.vue +++ b/src/views/RefundSwapSuccess.vue @@ -26,6 +26,7 @@ export default class SignBtcTransactionSuccess extends Vue { signerPubKey: this.keyguardResult.publicKey, }, this.keyguardResult, this.request.refund, { senderType: Nimiq.AccountType.HTLC, + recipientData: this.request.refund.extraData, })); const proof = new Nimiq.SerialBuffer(1 + tx.proof.length); diff --git a/src/views/SetupSwapSuccess.vue b/src/views/SetupSwapSuccess.vue index 94d2a4dc..b608e939 100644 --- a/src/views/SetupSwapSuccess.vue +++ b/src/views/SetupSwapSuccess.vue @@ -591,7 +591,7 @@ export default class SetupSwapSuccess extends BitcoinSyncBaseView { ...this.request.fund, recipient: new Nimiq.Address(new Uint8Array(20)), recipientType: Nimiq.AccountType.HTLC, - data: htlcInfo.fund.htlcData, + recipientData: htlcInfo.fund.htlcData, flags: 1 /* Nimiq.Transaction.Flag.CONTRACT_CREATION */, signerPubKey: nimiqSignatureResult.publicKey, signature: nimiqSignatureResult.signature, @@ -613,6 +613,7 @@ export default class SetupSwapSuccess extends BitcoinSyncBaseView { senderType: Nimiq.AccountType.HTLC, signerPubKey: nimiqSignatureResult.publicKey, signature: nimiqSignatureResult.signature, + recipientData: this.request.redeem.extraData, }); }