-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(abstract-utxo): add support for taproot descriptors
- Loading branch information
Showing
12 changed files
with
896 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 33 additions & 28 deletions
61
modules/abstract-utxo/test/core/descriptor/psbt/findDescriptors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,43 @@ | ||
import * as assert from 'assert'; | ||
|
||
import { getDefaultXPubs, getDescriptor } from '../descriptor.utils'; | ||
import { DescriptorTemplate, getDefaultXPubs, getDescriptor } from '../descriptor.utils'; | ||
import { findDescriptorForInput, findDescriptorForOutput } from '../../../../src/core/descriptor/psbt/findDescriptors'; | ||
|
||
import { mockPsbt } from './mock.utils'; | ||
|
||
describe('parsePsbt', function () { | ||
const descriptorA = getDescriptor('Wsh2Of3', getDefaultXPubs('a')); | ||
const descriptorB = getDescriptor('Wsh2Of3', getDefaultXPubs('b')); | ||
const descriptorMap = new Map([ | ||
['a', descriptorA], | ||
['b', descriptorB], | ||
]); | ||
function describeWithTemplates(tA: DescriptorTemplate, tB: DescriptorTemplate) { | ||
describe(`parsePsbt [${tA},${tB}]`, function () { | ||
const descriptorA = getDescriptor(tA, getDefaultXPubs('a')); | ||
const descriptorB = getDescriptor(tB, getDefaultXPubs('b')); | ||
const descriptorMap = new Map([ | ||
['a', descriptorA], | ||
['b', descriptorB], | ||
]); | ||
|
||
it('finds descriptors for PSBT inputs/outputs', function () { | ||
const psbt = mockPsbt( | ||
[ | ||
{ descriptor: descriptorA, index: 0 }, | ||
{ descriptor: descriptorB, index: 1, id: { vout: 1 } }, | ||
], | ||
[{ descriptor: descriptorA, index: 2, value: BigInt(1e6) }] | ||
); | ||
it('finds descriptors for PSBT inputs/outputs', function () { | ||
const psbt = mockPsbt( | ||
[ | ||
{ descriptor: descriptorA, index: 0 }, | ||
{ descriptor: descriptorB, index: 1, id: { vout: 1 } }, | ||
], | ||
[{ descriptor: descriptorA, index: 2, value: BigInt(1e6) }] | ||
); | ||
|
||
assert.deepStrictEqual(findDescriptorForInput(psbt.data.inputs[0], descriptorMap), { | ||
descriptor: descriptorA, | ||
index: 0, | ||
}); | ||
assert.deepStrictEqual(findDescriptorForInput(psbt.data.inputs[1], descriptorMap), { | ||
descriptor: descriptorB, | ||
index: 1, | ||
}); | ||
assert.deepStrictEqual(findDescriptorForOutput(psbt.txOutputs[0].script, psbt.data.outputs[0], descriptorMap), { | ||
descriptor: descriptorA, | ||
index: 2, | ||
assert.deepStrictEqual(findDescriptorForInput(psbt.data.inputs[0], descriptorMap), { | ||
descriptor: descriptorA, | ||
index: 0, | ||
}); | ||
assert.deepStrictEqual(findDescriptorForInput(psbt.data.inputs[1], descriptorMap), { | ||
descriptor: descriptorB, | ||
index: 1, | ||
}); | ||
assert.deepStrictEqual(findDescriptorForOutput(psbt.txOutputs[0].script, psbt.data.outputs[0], descriptorMap), { | ||
descriptor: descriptorA, | ||
index: 2, | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
describeWithTemplates('Wsh2Of3', 'Wsh2Of3'); | ||
describeWithTemplates('Wsh2Of3', 'Tr2Of3-NoKeyPath'); |
Oops, something went wrong.