-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rough] Things to work on (Roadmap?) #1437
Comments
Hi , |
Sure.
As for advice:
Once you get an issue up and running you can ask some more questions there. Thanks. |
Sounds great. I have few more questions i will ask in the issue then. |
Regarding "Async Hardware Wallet library", I'm interested in implementing it for the Ledger HW wallet since I'm already using ledger nano with psbt in my project. (I asked them if they planned to support bip174 LedgerHQ/ledgerjs#399) |
I added support for nonWitnessUtxo with segwit. (it just ignores the extra info, since the witnessUtxo is contained within the nonWitnessUtxo) So while not exactly the intended spec, you can use nonWitnessUtxo for all inputs in this library, and the segwit detection is done by matching scripts. Most other PSBT implementations don't do this though. So they should eventually support it. |
Great, even if it is just a patch waiting for ledgerjs implementing it. Another thing I need is a way to extract the unsigned transaction hex like I did with txb.buildIncomplete().toHex() since ledger.signP2SH needs serialized transaction outputs: atm i'm doing as follow: const outshex = btc.serializeTransactionOutputs(btc.splitTransaction((txb as any).__CACHE.__TX.toHex(), true)).toString('hex'); which is not a clean way. Maybe could be useful an additional extractTransactionIncomplete which ignores non-finalized inputs? |
hmmm.... tbh, I think the whole point of PSBT is that we have a format to encode Partially Signed Bitcoin Transactions... So having an extract incomplete method seems antithetical to the idea of PSBT. Your hack is OK for now. Let's wait until Ledger supports PSBT to fix it. :-D |
yea, I agree with you, let's wait :) TransportU2F.create().then(transport => {
const btc = new Btc(transport);
/* Download utxo transaction raw */
this.rawTransactions(options.utxos.map(utxo => utxo.tx)).then(transactions => {
/* Create inputs and serialized outputs */
const inputs = options.utxos.map(utxo => [
btc.splitTransaction(transactions[utxo.tx], bitcoinjs.Transaction.fromHex(transactions[utxo.tx]).hasWitnesses()),
utxo.n,
walletScripts.p2wsh.redeem.output.toString('hex'),
]);
const paths = inputs.map(i => this.signPath);
const txb = bitcoinjs.Psbt.fromHex(txhex, { network: this.config.network });
const outshex = btc.serializeTransactionOutputs(btc.splitTransaction((txb as any).__CACHE.__TX.toHex(), true)).toString('hex');
btc.signP2SHTransaction(inputs, paths, outshex, 0/*tx.locktime*/, 1 /*SIGHASH_ALL*/, segwit, 2).then(signatures => {
/* Inject signatures */
for (let j = 0; j < txb.inputCount; j++) {
txb.signInput(j, {
network: this.config.network,
publicKey: toByteArray(publickey),
sign: (hash) => bitcoinjs.script.signature.decode(toByteArray(signatures[j])).signature
} as bitcoinjs.ECPairInterface);
}
/* Build the transaction */
resolve(txb.toHex());
});
});
}); And this is the code for retrieving the pubkey: private getPublicKeyFromPath(path: string) {
return new Promise((resolve, reject) => {
TransportU2F.create().then(transport => {
const btc = new Btc(transport);
btc.getWalletPublicKey(path, { verify: false, format: 'legacy' }).then(result => {
const comppk = compressPublicKey(result.publicKey);
resolve(comppk);
}).catch(err => {
reject(err);
});
}).catch(err => {
reject(err);
});
});
}; |
Very cool. I would like to see the bigger project. Not sure where publickey is coming from etc. |
@junderw I put the getpubkey function in the previous message; anyway for further details the frontend wallet part of our platform is opensource: https://github.com/helperbit/helperbit-wallet |
Any other ideas for future projects are welcome.
The text was updated successfully, but these errors were encountered: