Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13711142
D16614.id49124.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D16614.id49124.diff
View Options
diff --git a/apps/token-server/src/transactions.ts b/apps/token-server/src/transactions.ts
--- a/apps/token-server/src/transactions.ts
+++ b/apps/token-server/src/transactions.ts
@@ -190,6 +190,10 @@
// Add and sign required inputUtxos to create tx with specified targetOutputs
for (const utxo of utxos!) {
+ if ('token' in utxo) {
+ // We do not add token utxos for required inputSatoshis
+ continue;
+ }
if (needsAnotherUtxo) {
// If inputSatoshis is less than or equal to satoshisToSend, we know we need
// to add another input
@@ -245,7 +249,6 @@
// Otherwise, broadcast the tx
const txSer = tx.ser();
const hex = toHex(txSer);
- console.log(`reward tx hex`, hex);
// Will throw error on node failing to broadcast tx
// e.g. 'txn-mempool-conflict (code 18)'
const response = await chronik.broadcastTx(hex);
@@ -253,5 +256,5 @@
return { hex, response };
}
// If we go over all input utxos but do not have enough to send the tx, throw Insufficient funds error
- throw new Error('Insufficient funds');
+ throw new Error('Insufficient XEC utxos to complete tx');
};
diff --git a/apps/token-server/test/vectors.ts b/apps/token-server/test/vectors.ts
--- a/apps/token-server/test/vectors.ts
+++ b/apps/token-server/test/vectors.ts
@@ -1094,6 +1094,33 @@
destinationAddress: MOCK_DESTINATION_ADDRESS,
error: new Error('Insufficient token utxos'),
},
+ {
+ description:
+ 'Expected error if insufficient non-token utxos to send a tx',
+ wallet: MOCK_WALLET,
+ utxos: [
+ // Only token utxos are available
+ // Enough XEC to send the tx, but only if token amounts are calculated properly
+ // TODO optimize token utxo selection for xec-free txs
+ {
+ ...MOCK_SPENDABLE_TOKEN_UTXO,
+ outpoint: { ...MOCK_OUTPOINT, outIdx: 2 },
+ },
+ {
+ ...MOCK_SPENDABLE_TOKEN_UTXO,
+ outpoint: { ...MOCK_OUTPOINT, outIdx: 3 },
+ },
+ {
+ ...MOCK_SPENDABLE_TOKEN_UTXO,
+ outpoint: { ...MOCK_OUTPOINT, outIdx: 1 },
+ token: { ...MOCK_UTXO_TOKEN, amount: '2' },
+ },
+ ],
+ tokenId: MOCK_TOKENID_ONES,
+ rewardAmountTokenSats: 2n,
+ destinationAddress: MOCK_DESTINATION_ADDRESS,
+ error: new Error('Insufficient XEC utxos to complete tx'),
+ },
],
},
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 26, 10:35 (5 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5573291
Default Alt Text
D16614.id49124.diff (2 KB)
Attached To
D16614: [token-server] Do not add token utxos for required satoshi inputs
Event Timeline
Log In to Comment