Skip to content

Commit 86b4039

Browse files
authored
Merge pull request #782 from Roasbeef/v0-3-3-branch
release: create v0.3.3 rc2 release branch
2 parents f7c543d + 68ca29c commit 86b4039

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2292
-1120
lines changed

asset/asset.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import (
1010
"io"
1111
"reflect"
1212
"strings"
13+
"time"
1314
"unicode"
1415
"unicode/utf8"
1516

1617
"github.com/btcsuite/btcd/blockchain"
1718
"github.com/btcsuite/btcd/btcec/v2"
1819
"github.com/btcsuite/btcd/btcec/v2/schnorr"
20+
"github.com/btcsuite/btcd/chaincfg/chainhash"
1921
"github.com/btcsuite/btcd/txscript"
2022
"github.com/btcsuite/btcd/wire"
2123
"github.com/lightninglabs/lndclient"
@@ -1418,3 +1420,53 @@ func ValidateAssetName(name string) error {
14181420

14191421
return nil
14201422
}
1423+
1424+
// ChainAsset is a wrapper around the base asset struct that includes
1425+
// information detailing where in the chain the asset is currently anchored.
1426+
type ChainAsset struct {
1427+
*Asset
1428+
1429+
// IsSpent indicates whether the above asset was previously spent.
1430+
IsSpent bool
1431+
1432+
// AnchorTx is the transaction that anchors this chain asset.
1433+
AnchorTx *wire.MsgTx
1434+
1435+
// AnchorBlockHash is the blockhash that mined the anchor tx.
1436+
AnchorBlockHash chainhash.Hash
1437+
1438+
// AnchorBlockHeight is the height of the block that mined the anchor
1439+
// tx.
1440+
AnchorBlockHeight uint32
1441+
1442+
// AnchorOutpoint is the outpoint that commits to the asset.
1443+
AnchorOutpoint wire.OutPoint
1444+
1445+
// AnchorInternalKey is the raw internal key that was used to create the
1446+
// anchor Taproot output key.
1447+
AnchorInternalKey *btcec.PublicKey
1448+
1449+
// AnchorMerkleRoot is the Taproot merkle root hash of the anchor output
1450+
// the asset was committed to. If there is no Tapscript sibling, this is
1451+
// equal to the Taproot Asset root commitment hash.
1452+
AnchorMerkleRoot []byte
1453+
1454+
// AnchorTapscriptSibling is the serialized preimage of a Tapscript
1455+
// sibling, if there was one. If this is empty, then the
1456+
// AnchorTapscriptSibling hash is equal to the Taproot root hash of the
1457+
// anchor output.
1458+
AnchorTapscriptSibling []byte
1459+
1460+
// AnchorLeaseOwner is the identity of the application that currently
1461+
// has a lease on this UTXO. If empty/nil, then the UTXO is not
1462+
// currently leased. A lease means that the UTXO is being
1463+
// reserved/locked to be spent in an upcoming transaction and that it
1464+
// should not be available for coin selection through any of the wallet
1465+
// RPCs.
1466+
AnchorLeaseOwner [32]byte
1467+
1468+
// AnchorLeaseExpiry is the expiry of the lease. If the expiry is nil or
1469+
// the time is in the past, then the lease is not valid and the UTXO is
1470+
// available for coin selection.
1471+
AnchorLeaseExpiry *time.Time
1472+
}

cmd/tapcli/universe.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/hex"
66
"fmt"
77

8+
"github.com/btcsuite/btcd/wire"
89
tap "github.com/lightninglabs/taproot-assets"
910
"github.com/lightninglabs/taproot-assets/fn"
1011
"github.com/lightninglabs/taproot-assets/proof"
@@ -413,7 +414,7 @@ func parseAssetKey(ctx *cli.Context) (*unirpc.AssetKey, error) {
413414
return nil, fmt.Errorf("outpoint and script key must be set")
414415
}
415416

416-
outpoint, err := tap.UnmarshalOutpoint(ctx.String(outpointName))
417+
outpoint, err := wire.NewOutPointFromString(ctx.String(outpointName))
417418
if err != nil {
418419
return nil, err
419420
}

itest/addrs_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66

77
"github.com/btcsuite/btcd/btcec/v2/schnorr"
8+
"github.com/btcsuite/btcd/wire"
89
tap "github.com/lightninglabs/taproot-assets"
910
"github.com/lightninglabs/taproot-assets/fn"
1011
"github.com/lightninglabs/taproot-assets/internal/test"
@@ -515,16 +516,34 @@ func runMultiSendTest(ctxt context.Context, t *harnessTest, alice,
515516

516517
// sendProof manually exports a proof from the given source node and imports it
517518
// using the development only ImportProof RPC on the destination node.
518-
func sendProof(t *harnessTest, src, dst *tapdHarness, scriptKey []byte,
519+
func sendProof(t *harnessTest, src, dst *tapdHarness,
520+
sendResp *taprpc.SendAssetResponse, scriptKey []byte,
519521
genInfo *taprpc.GenesisInfo) *tapdevrpc.ImportProofResponse {
520522

521523
ctxb := context.Background()
522524

525+
// We need to find the outpoint of the asset we sent to the address.
526+
var outpoint *taprpc.OutPoint
527+
for _, out := range sendResp.Transfer.Outputs {
528+
if bytes.Equal(out.ScriptKey, scriptKey) {
529+
wireOutPoint, err := wire.NewOutPointFromString(
530+
out.Anchor.Outpoint,
531+
)
532+
require.NoError(t.t, err)
533+
534+
outpoint = &taprpc.OutPoint{
535+
Txid: wireOutPoint.Hash[:],
536+
OutputIndex: wireOutPoint.Index,
537+
}
538+
}
539+
}
540+
523541
var proofResp *taprpc.ProofFile
524542
waitErr := wait.NoError(func() error {
525543
resp, err := src.ExportProof(ctxb, &taprpc.ExportProofRequest{
526544
AssetId: genInfo.AssetId,
527545
ScriptKey: scriptKey,
546+
Outpoint: outpoint,
528547
})
529548
if err != nil {
530549
return err

itest/psbt_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func testPsbtScriptHashLockSend(t *harnessTest) {
132132
// This is an interactive/PSBT based transfer, so we do need to manually
133133
// send the proof from the sender to the receiver because the proof
134134
// courier address gets lost in the address->PSBT conversion.
135-
_ = sendProof(t, bob, alice, aliceAddr.ScriptKey, genInfo)
135+
_ = sendProof(t, bob, alice, sendResp, aliceAddr.ScriptKey, genInfo)
136136
AssertNonInteractiveRecvComplete(t.t, alice, 1)
137137

138138
aliceAssets, err := alice.ListAssets(ctxb, &taprpc.ListAssetRequest{
@@ -258,7 +258,7 @@ func testPsbtScriptCheckSigSend(t *harnessTest) {
258258
// This is an interactive/PSBT based transfer, so we do need to manually
259259
// send the proof from the sender to the receiver because the proof
260260
// courier address gets lost in the address->PSBT conversion.
261-
_ = sendProof(t, bob, alice, aliceAddr.ScriptKey, genInfo)
261+
_ = sendProof(t, bob, alice, sendResp, aliceAddr.ScriptKey, genInfo)
262262
AssertNonInteractiveRecvComplete(t.t, alice, 1)
263263

264264
aliceAssets, err := alice.ListAssets(ctxb, &taprpc.ListAssetRequest{
@@ -434,7 +434,7 @@ func runPsbtInteractiveFullValueSendTest(ctxt context.Context, t *harnessTest,
434434
// This is an interactive transfer, so we do need to manually
435435
// send the proof from the sender to the receiver.
436436
_ = sendProof(
437-
t, sender, receiver,
437+
t, sender, receiver, sendResp,
438438
receiverScriptKey.PubKey.SerializeCompressed(), genInfo,
439439
)
440440

@@ -647,7 +647,7 @@ func runPsbtInteractiveSplitSendTest(ctxt context.Context, t *harnessTest,
647647
// This is an interactive transfer, so we do need to manually
648648
// send the proof from the sender to the receiver.
649649
_ = sendProof(
650-
t, sender, receiver,
650+
t, sender, receiver, sendResp,
651651
receiverScriptKey.PubKey.SerializeCompressed(), genInfo,
652652
)
653653

@@ -769,7 +769,7 @@ func testPsbtInteractiveTapscriptSibling(t *harnessTest) {
769769
// This is an interactive transfer, so we do need to manually send the
770770
// proof from the sender to the receiver.
771771
_ = sendProof(
772-
t, alice, bob,
772+
t, alice, bob, sendResp,
773773
receiverScriptKey.PubKey.SerializeCompressed(), genInfo,
774774
)
775775

@@ -916,11 +916,11 @@ func testPsbtMultiSend(t *harnessTest) {
916916
// This is an interactive transfer, so we do need to manually send the
917917
// proof from the sender to the receiver.
918918
_ = sendProof(
919-
t, sender, receiver,
919+
t, sender, receiver, sendResp,
920920
receiverScriptKey1.PubKey.SerializeCompressed(), genInfo,
921921
)
922922
_ = sendProof(
923-
t, sender, receiver,
923+
t, sender, receiver, sendResp,
924924
receiverScriptKey2.PubKey.SerializeCompressed(), genInfo,
925925
)
926926

itest/round_trip_send_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func testRoundTripSend(t *harnessTest) {
127127
// recipient's output is the second one.
128128
bobToAliceOutput := transferResp.Transfers[0].Outputs[1]
129129
bobToAliceAnchor := bobToAliceOutput.Anchor
130-
outpoint, err := ParseOutPoint(bobToAliceAnchor.Outpoint)
130+
outpoint, err := wire.NewOutPointFromString(bobToAliceAnchor.Outpoint)
131131
require.NoError(t.t, err)
132132

133133
internalKey, err := btcec.ParsePubKey(bobToAliceAnchor.InternalKey)

itest/test_list_on_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var testCases = []*testCase{
4141
test: testReOrgMintAndSend,
4242
},
4343
{
44-
name: "basic send unidirectional",
44+
name: "basic send unidirectional hashmail courier",
4545
test: testBasicSendUnidirectional,
4646
proofCourierType: proof.HashmailCourierType,
4747
},
@@ -54,7 +54,8 @@ var testCases = []*testCase{
5454
test: testRestartReceiverCheckBalance,
5555
},
5656
{
57-
name: "resume pending package send",
57+
name: "resume pending package send hashmail " +
58+
"courier",
5859
test: testResumePendingPackageSend,
5960
proofCourierType: proof.HashmailCourierType,
6061
},
@@ -72,7 +73,8 @@ var testCases = []*testCase{
7273
test: testReattemptFailedReceiveUniCourier,
7374
},
7475
{
75-
name: "offline receiver eventually receives",
76+
name: "offline receiver eventually receives " +
77+
"hashmail courier",
7678
test: testOfflineReceiverEventuallyReceives,
7779
proofCourierType: proof.HashmailCourierType,
7880
},
@@ -81,7 +83,7 @@ var testCases = []*testCase{
8183
test: testSendNoCourierUniverseImport,
8284
},
8385
{
84-
name: "basic send passive asset",
86+
name: "basic send passive asset hashmail courier",
8587
test: testBasicSendPassiveAsset,
8688
proofCourierType: proof.HashmailCourierType,
8789
},
@@ -123,7 +125,7 @@ var testCases = []*testCase{
123125
test: testMintMultiAssetGroups,
124126
},
125127
{
126-
name: "sending multi asset groups",
128+
name: "sending multi asset groups hashmail courier",
127129
test: testMultiAssetGroupSend,
128130
proofCourierType: proof.HashmailCourierType,
129131
},

itest/universe_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/btcsuite/btcd/btcec/v2"
1313
"github.com/btcsuite/btcd/btcec/v2/schnorr"
14+
"github.com/btcsuite/btcd/wire"
1415
tap "github.com/lightninglabs/taproot-assets"
1516
"github.com/lightninglabs/taproot-assets/asset"
1617
"github.com/lightninglabs/taproot-assets/fn"
@@ -150,7 +151,7 @@ func testUniverseSync(t *harnessTest) {
150151
// query for that asset with the compressed script key.
151152
firstAssetID := rpcSimpleAssets[0].AssetGenesis.AssetId
152153
firstScriptKey := hex.EncodeToString(rpcSimpleAssets[0].ScriptKey)
153-
firstOutpoint, err := tap.UnmarshalOutpoint(
154+
firstOutpoint, err := wire.NewOutPointFromString(
154155
rpcSimpleAssets[0].ChainAnchor.AnchorOutpoint,
155156
)
156157
require.NoError(t.t, err)
@@ -297,7 +298,7 @@ func testUniverseManualSync(t *harnessTest) {
297298

298299
// We should also be able to fetch an asset from Bob's Universe, and
299300
// query for that asset with the compressed script key.
300-
firstOutpoint, err := tap.UnmarshalOutpoint(
301+
firstOutpoint, err := wire.NewOutPointFromString(
301302
firstAsset.ChainAnchor.AnchorOutpoint,
302303
)
303304
require.NoError(t.t, err)

itest/utils.go

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ package itest
22

33
import (
44
"context"
5-
"fmt"
6-
"strconv"
7-
"strings"
85
"testing"
96
"time"
107

@@ -44,34 +41,10 @@ func CopyRequests(
4441
return copied
4542
}
4643

47-
// ParseOutPoint
48-
func ParseOutPoint(s string) (*wire.OutPoint, error) {
49-
split := strings.Split(s, ":")
50-
if len(split) != 2 {
51-
return nil, fmt.Errorf("expecting outpoint to be in format " +
52-
"of: txid:index")
53-
}
54-
55-
index, err := strconv.ParseInt(split[1], 10, 32)
56-
if err != nil {
57-
return nil, fmt.Errorf("unable to decode output index: %v", err)
58-
}
59-
60-
txid, err := chainhash.NewHashFromStr(split[0])
61-
if err != nil {
62-
return nil, fmt.Errorf("unable to parse hex string: %v", err)
63-
}
64-
65-
return &wire.OutPoint{
66-
Hash: *txid,
67-
Index: uint32(index),
68-
}, nil
69-
}
70-
7144
// ParseGenInfo converts a taprpc.GenesisInfo into its asset.Genesis
7245
// counterpart.
7346
func ParseGenInfo(t *testing.T, genInfo *taprpc.GenesisInfo) *asset.Genesis {
74-
genPoint, err := ParseOutPoint(genInfo.GenesisPoint)
47+
genPoint, err := wire.NewOutPointFromString(genInfo.GenesisPoint)
7548
require.NoError(t, err)
7649

7750
parsedGenesis := asset.Genesis{

0 commit comments

Comments
 (0)