-
Notifications
You must be signed in to change notification settings - Fork 137
tapgarden: list batches correctly after asset transfer #992
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cda2a9e
tapgarden: add helpers for reading finalized batch
jharveyb b06eba1
tapgarden+proof: complete mock proof archiver
jharveyb 56169ac
tapdb: return seedlings for a finalized batch
jharveyb 154644f
proof+tapdb: add FetchIssuanceProof to Archiver
jharveyb 660940e
tapdb: add FetchScriptKeyStore interface
jharveyb 4f16d2d
tapgarden: fetch finalized batch via file archiver
jharveyb 62b431e
itest: check batch equality after a transfer
jharveyb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -412,7 +412,21 @@ func (b *BatchCaretaker) assetCultivator() { | |
| } | ||
| } | ||
|
|
||
| // extractGenesisOutpoint extracts the genesis point (the first output from the | ||
| // extractAnchorOutputIndex extracts the anchor output index from a funded | ||
| // genesis packet. | ||
| func extractAnchorOutputIndex(genesisPkt *tapsend.FundedPsbt) uint32 { | ||
| anchorOutputIndex := uint32(0) | ||
|
|
||
| // TODO(jhb): Does funding guarantee that minting TXs always have | ||
| // exactly two outputs? If not this func should be fallible. | ||
| if genesisPkt.ChangeOutputIndex == 0 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the current |
||
| anchorOutputIndex = 1 | ||
| } | ||
|
|
||
| return anchorOutputIndex | ||
| } | ||
|
|
||
| // extractGenesisOutpoint extracts the genesis point (the first input from the | ||
| // genesis transaction). | ||
| func extractGenesisOutpoint(tx *wire.MsgTx) wire.OutPoint { | ||
| return tx.TxIn[0].PreviousOutPoint | ||
|
|
@@ -436,7 +450,6 @@ func (b *BatchCaretaker) seedlingsToAssetSprouts(ctx context.Context, | |
| b.cfg.Batch.Seedlings, | ||
| ) | ||
| groupedSeedlingCount := len(groupedSeedlings) | ||
|
|
||
| // load seedling asset groups and check for correct group count | ||
| seedlingGroups, err := b.cfg.Log.FetchSeedlingGroups( | ||
| ctx, genesisPoint, assetOutputIndex, | ||
|
|
@@ -453,10 +466,9 @@ func (b *BatchCaretaker) seedlingsToAssetSprouts(ctx context.Context, | |
| seedlingGroupCount) | ||
| } | ||
|
|
||
| for i := range seedlingGroups { | ||
| for _, seedlingGroup := range seedlingGroups { | ||
| // check that asset group has a witness, and that the group | ||
| // has a matching seedling | ||
| seedlingGroup := seedlingGroups[i] | ||
| if len(seedlingGroup.GroupKey.Witness) == 0 { | ||
| return nil, fmt.Errorf("not all seedling groups have " + | ||
| "witnesses") | ||
|
|
@@ -496,12 +508,7 @@ func (b *BatchCaretaker) seedlingsToAssetSprouts(ctx context.Context, | |
| // build assets for ungrouped seedlings | ||
| for seedlingName := range ungroupedSeedlings { | ||
| seedling := ungroupedSeedlings[seedlingName] | ||
| assetGen := asset.Genesis{ | ||
| FirstPrevOut: genesisPoint, | ||
| Tag: seedling.AssetName, | ||
| OutputIndex: assetOutputIndex, | ||
| Type: seedling.AssetType, | ||
| } | ||
| assetGen := seedling.Genesis(genesisPoint, assetOutputIndex) | ||
|
|
||
| // If the seedling has a meta data reveal set, then we'll bind | ||
| // that by including the hash of the meta data in the asset | ||
|
|
@@ -607,11 +614,9 @@ func (b *BatchCaretaker) stateStep(currentState BatchState) (BatchState, error) | |
| // and vice versa. | ||
| // TODO(jhb): return the anchor index instead of change? or both | ||
| // so this works for N outputs | ||
| b.anchorOutputIndex = 0 | ||
| if changeOutputIndex == 0 { | ||
| b.anchorOutputIndex = 1 | ||
| } | ||
|
|
||
| b.anchorOutputIndex = extractAnchorOutputIndex( | ||
| b.cfg.Batch.GenesisPacket, | ||
| ) | ||
| genesisPoint := extractGenesisOutpoint(genesisTxPkt.UnsignedTx) | ||
|
|
||
| // First, we'll turn all the seedlings into actual taproot assets. | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.