Skip to content
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

Sign unknown inputs #85

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export {
export { OP, RawTx, CompactSize, Script, ScriptNum } from './script.js';
export { Transaction } from './transaction.js';
export { selectUTXO } from './utxo.js';
export { NETWORK, compareBytes as _cmpBytes, TAPROOT_UNSPENDABLE_KEY } from './utils.js';
export {
NETWORK,
TEST_NETWORK,
compareBytes as _cmpBytes,
TAPROOT_UNSPENDABLE_KEY,
} from './utils.js';

// Utils
// prettier-ignore
Expand Down
10 changes: 7 additions & 3 deletions src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,13 @@ export class Transaction {
} else if (inputType.last.type === 'wpkh') {
inputScript = P.EMPTY;
witness = [input.partialSig[0][1], input.partialSig[0][0]];
} else if (inputType.last.type === 'unknown' && !this.opts.allowUnknownInputs)
throw new Error('Unknown inputs not allowed');

} else if (inputType.last.type === 'unknown') {
if (!this.opts.allowUnknownInputs) {
throw new Error('Unknown inputs not allowed');
}
// Trying our best to sign what we can
inputScript = Script.encode([input.partialSig[0][1], input.partialSig[0][0]]);
}
// Create final scripts (generic part)
let finalScriptSig: Bytes | undefined, finalScriptWitness: Bytes[] | undefined;
if (inputType.type.includes('wsh-')) {
Expand Down