Skip to content

Commit 189f7c2

Browse files
committed
f: can send collateral now
1 parent c4b789b commit 189f7c2

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

public/wallet-app.js

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,17 @@
353353

354354
let dust = Math.floor(dustF);
355355
let utxos = getAllUtxos();
356-
let memo = { satoshis: dust, memo: '\0' };
357-
let draftTx = await draftWalletTx(utxos, null, memo);
358-
draftTx.outputs[0].satoshis = 0;
359-
draftTx.feeTarget += dust;
356+
let memo = { satoshis: dust, memo: '' };
357+
let draft = await draftWalletTx(utxos, null, memo);
358+
console.log('draftTx');
359+
console.log(draft);
360+
draft.tx.outputs[0].satoshis = 0;
361+
draft.tx.feeTarget += dust;
362+
363+
draft.tx.inputs.sort(DashTx.sortInputs);
364+
draft.tx.outputs.sort(DashTx.sortOutputs);
365+
let signedTx = await dashTx.legacy.finalizePresorted(draft.tx);
366+
console.log(signedTx);
360367
};
361368

362369
async function draftWalletTx(utxos, inputs, output) {
@@ -386,17 +393,20 @@
386393
output.satoshis = 0;
387394
continue;
388395
}
389-
if (!output.address && typeof output.memo !== 'string') {
390-
let err = new Error(`output is missing 'address' and 'pubKeyHash'`);
391-
window.alert(err.message);
392-
throw err;
396+
if (!output.address) {
397+
if (typeof output.memo !== 'string') {
398+
let err = new Error(`output is missing 'address' and 'pubKeyHash'`);
399+
window.alert(err.message);
400+
throw err;
401+
}
402+
} else {
403+
let pkhBytes = await DashKeys.addrToPkh(output.address, {
404+
version: network,
405+
});
406+
Object.assign(output, {
407+
pubKeyHash: DashKeys.utils.bytesToHex(pkhBytes),
408+
});
393409
}
394-
let pkhBytes = await DashKeys.addrToPkh(output.address, {
395-
version: network,
396-
});
397-
Object.assign(output, {
398-
pubKeyHash: DashKeys.utils.bytesToHex(pkhBytes),
399-
});
400410
}
401411

402412
draftTx.inputs.sort(DashTx.sortInputs);

0 commit comments

Comments
 (0)