From 0fb1b363b7fbc1f3b6ceb6dd7b86c0d9a94745fa Mon Sep 17 00:00:00 2001 From: mainnet-pat Date: Thu, 8 Dec 2022 18:25:50 +0000 Subject: [PATCH 1/2] Add token info to input and output generation routines --- src/lib/message/transaction-types.ts | 7 +++++++ src/lib/transaction/generate-transaction.ts | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/lib/message/transaction-types.ts b/src/lib/message/transaction-types.ts index af09ffce..e563ec7a 100644 --- a/src/lib/message/transaction-types.ts +++ b/src/lib/message/transaction-types.ts @@ -328,6 +328,13 @@ export interface CompilationDirectiveUnlocking< * Required for use in signing serializations. */ valueSatoshis: Output['valueSatoshis']; + + /** + * The CashToken contents of this output. This property is only defined if the + * output contains one or more tokens. For details, see + * `CHIP-2022-02-CashTokens`. + */ + token?: Output['token']; } export interface CompilationDirectiveUnlockingEstimate< diff --git a/src/lib/transaction/generate-transaction.ts b/src/lib/transaction/generate-transaction.ts index 29e1408f..6163aa3e 100644 --- a/src/lib/transaction/generate-transaction.ts +++ b/src/lib/transaction/generate-transaction.ts @@ -73,12 +73,14 @@ export const compileOutputTemplate = < ? { lockingBytecode: result.bytecode, valueSatoshis: outputTemplate.valueSatoshis, + token: outputTemplate.token, } : returnFailedCompilationDirective({ index, result, type: 'locking' }); } return { lockingBytecode: outputTemplate.lockingBytecode.slice(), valueSatoshis: outputTemplate.valueSatoshis, + token: outputTemplate.token, }; }; @@ -108,6 +110,7 @@ export const compileInputTemplate = < sourceOutputs[index] = { lockingBytecode: Uint8Array.of(), valueSatoshis: inputTemplate.unlockingBytecode.valueSatoshis, + token: inputTemplate.unlockingBytecode.token, }; const result = directive.compiler.generateBytecode({ data: { From 5700ab6cf4daa936108b1d5d84938f079962d01b Mon Sep 17 00:00:00 2001 From: mainnet-pat Date: Thu, 8 Dec 2022 18:36:22 +0000 Subject: [PATCH 2/2] Fix documentation --- src/lib/message/transaction-types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/message/transaction-types.ts b/src/lib/message/transaction-types.ts index e563ec7a..3e2ebe4a 100644 --- a/src/lib/message/transaction-types.ts +++ b/src/lib/message/transaction-types.ts @@ -330,8 +330,8 @@ export interface CompilationDirectiveUnlocking< valueSatoshis: Output['valueSatoshis']; /** - * The CashToken contents of this output. This property is only defined if the - * output contains one or more tokens. For details, see + * The CashToken contents of this input. This property is only defined if the + * input contains one or more tokens. For details, see * `CHIP-2022-02-CashTokens`. */ token?: Output['token'];