From 97a843f3cd2a107c1e44d1957a678aba5108cb13 Mon Sep 17 00:00:00 2001 From: carla Date: Mon, 25 May 2020 08:38:25 +0200 Subject: [PATCH] walletrpc: add LabelTransaction rpc --- lnrpc/walletrpc/walletkit.pb.go | 290 ++++++++++++++++++------- lnrpc/walletrpc/walletkit.proto | 23 ++ lnrpc/walletrpc/walletkit.swagger.json | 3 + lnrpc/walletrpc/walletkit_server.go | 33 +++ lntest/itest/lnd_test.go | 100 +++++++-- lntest/itest/log_error_whitelist.txt | 2 + 6 files changed, 361 insertions(+), 90 deletions(-) diff --git a/lnrpc/walletrpc/walletkit.pb.go b/lnrpc/walletrpc/walletkit.pb.go index 94487a87..721a6a56 100644 --- a/lnrpc/walletrpc/walletkit.pb.go +++ b/lnrpc/walletrpc/walletkit.pb.go @@ -997,6 +997,95 @@ func (m *ListSweepsResponse_TransactionIDs) GetTransactionIds() []string { return nil } +type LabelTransactionRequest struct { + // The txid of the transaction to label. + Txid []byte `protobuf:"bytes,1,opt,name=txid,proto3" json:"txid,omitempty"` + // The label to add to the transaction, limited to 500 characters. + Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` + // Whether to overwrite the existing label, if it is present. + Overwrite bool `protobuf:"varint,3,opt,name=overwrite,proto3" json:"overwrite,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LabelTransactionRequest) Reset() { *m = LabelTransactionRequest{} } +func (m *LabelTransactionRequest) String() string { return proto.CompactTextString(m) } +func (*LabelTransactionRequest) ProtoMessage() {} +func (*LabelTransactionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6cc6942ac78249e5, []int{16} +} + +func (m *LabelTransactionRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_LabelTransactionRequest.Unmarshal(m, b) +} +func (m *LabelTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_LabelTransactionRequest.Marshal(b, m, deterministic) +} +func (m *LabelTransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_LabelTransactionRequest.Merge(m, src) +} +func (m *LabelTransactionRequest) XXX_Size() int { + return xxx_messageInfo_LabelTransactionRequest.Size(m) +} +func (m *LabelTransactionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_LabelTransactionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_LabelTransactionRequest proto.InternalMessageInfo + +func (m *LabelTransactionRequest) GetTxid() []byte { + if m != nil { + return m.Txid + } + return nil +} + +func (m *LabelTransactionRequest) GetLabel() string { + if m != nil { + return m.Label + } + return "" +} + +func (m *LabelTransactionRequest) GetOverwrite() bool { + if m != nil { + return m.Overwrite + } + return false +} + +type LabelTransactionResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LabelTransactionResponse) Reset() { *m = LabelTransactionResponse{} } +func (m *LabelTransactionResponse) String() string { return proto.CompactTextString(m) } +func (*LabelTransactionResponse) ProtoMessage() {} +func (*LabelTransactionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6cc6942ac78249e5, []int{17} +} + +func (m *LabelTransactionResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_LabelTransactionResponse.Unmarshal(m, b) +} +func (m *LabelTransactionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_LabelTransactionResponse.Marshal(b, m, deterministic) +} +func (m *LabelTransactionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_LabelTransactionResponse.Merge(m, src) +} +func (m *LabelTransactionResponse) XXX_Size() int { + return xxx_messageInfo_LabelTransactionResponse.Size(m) +} +func (m *LabelTransactionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_LabelTransactionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_LabelTransactionResponse proto.InternalMessageInfo + func init() { proto.RegisterEnum("walletrpc.WitnessType", WitnessType_name, WitnessType_value) proto.RegisterType((*KeyReq)(nil), "walletrpc.KeyReq") @@ -1016,87 +1105,93 @@ func init() { proto.RegisterType((*ListSweepsRequest)(nil), "walletrpc.ListSweepsRequest") proto.RegisterType((*ListSweepsResponse)(nil), "walletrpc.ListSweepsResponse") proto.RegisterType((*ListSweepsResponse_TransactionIDs)(nil), "walletrpc.ListSweepsResponse.TransactionIDs") + proto.RegisterType((*LabelTransactionRequest)(nil), "walletrpc.LabelTransactionRequest") + proto.RegisterType((*LabelTransactionResponse)(nil), "walletrpc.LabelTransactionResponse") } func init() { proto.RegisterFile("walletrpc/walletkit.proto", fileDescriptor_6cc6942ac78249e5) } var fileDescriptor_6cc6942ac78249e5 = []byte{ - // 1190 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x6d, 0x6f, 0xda, 0xd6, - 0x17, 0x6f, 0x42, 0x20, 0x70, 0x78, 0x08, 0xb9, 0xe4, 0x81, 0xd2, 0xf4, 0x9f, 0xfc, 0x3d, 0x6d, - 0x8b, 0xb6, 0x96, 0x68, 0xa9, 0x36, 0xad, 0x9d, 0x34, 0x8d, 0x80, 0x23, 0x10, 0x04, 0x33, 0xdb, - 0x2d, 0xea, 0xde, 0x5c, 0x19, 0x7c, 0x4b, 0xac, 0x80, 0xed, 0x5e, 0x5f, 0x0a, 0xbc, 0xdb, 0x9b, - 0x7d, 0x85, 0x49, 0xfd, 0xb6, 0x93, 0xaf, 0x1f, 0xb8, 0x86, 0xa5, 0xd2, 0x5e, 0x85, 0x7b, 0x7e, - 0xbf, 0xf3, 0x7c, 0x7c, 0x4e, 0xe0, 0xe9, 0xc2, 0x98, 0x4e, 0x09, 0xa3, 0xee, 0xf8, 0x2a, 0xf8, - 0xf5, 0x60, 0xb1, 0xba, 0x4b, 0x1d, 0xe6, 0xa0, 0x5c, 0x0c, 0xd5, 0x72, 0xd4,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 0x7d, 0x54, 0xf3, - 0x17, 0xc8, 0xfa, 0xfe, 0xfc, 0xa3, 0x8d, 0xc4, 0x15, 0x2e, 0x1c, 0xf5, 0xda, 0xe9, 0x96, 0x3c, - 0xfc, 0x90, 0xda, 0x80, 0xc2, 0x6b, 0x2c, 0x1e, 0x74, 0xd1, 0x8c, 0x20, 0xaf, 0xd5, 0xc4, 0x85, - 0xb4, 0x71, 0xc4, 0x7b, 0x90, 0x17, 0x6e, 0x25, 0x7a, 0x2e, 0x50, 0xb7, 0xef, 0x76, 0xed, 0x7f, - 0x8f, 0xc1, 0x6b, 0x6b, 0xc2, 0x51, 0x4c, 0x58, 0xdb, 0xbe, 0xb1, 0x09, 0x6b, 0xff, 0x76, 0x4b, - 0x55, 0x28, 0x26, 0x36, 0x2f, 0x3a, 0x7f, 0x64, 0xb3, 0xc6, 0xf1, 0x5d, 0x3c, 0x4e, 0x08, 0x6d, - 0xfe, 0x06, 0xfb, 0xe1, 0x6e, 0x43, 0x4f, 0x05, 0x72, 0x72, 0x0f, 0x27, 0x2a, 0xb6, 0xb1, 0x0a, - 0x51, 0x07, 0x60, 0xbd, 0x54, 0xd0, 0xd9, 0x23, 0xbb, 0x26, 0xb0, 0xf3, 0xfc, 0x8b, 0x9b, 0xe8, - 0xe6, 0x87, 0x3f, 0xae, 0x26, 0x16, 0xbb, 0x9f, 0x8f, 0xea, 0x63, 0x67, 0x76, 0x35, 0xf5, 0xaf, - 0xa0, 0x6d, 0xd9, 0x13, 0x9b, 0xb0, 0x85, 0x43, 0x1f, 0xae, 0xa6, 0xb6, 0x79, 0xc5, 0x77, 0xe2, - 0x55, 0x6c, 0x65, 0x94, 0xe1, 0xff, 0x50, 0xbe, 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0xde, 0x94, - 0x5b, 0x29, 0x99, 0x0a, 0x00, 0x00, + // 1255 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,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x85, 0x47, 0xdf, 0x73, 0x1d, 0x9f, 0x20, 0xc2, 0x86, 0x69, 0x59, 0x94, 0x73, 0x17, 0x54, 0xfe, + 0x2d, 0xbd, 0x86, 0xa2, 0x4e, 0x4d, 0xc7, 0x37, 0x87, 0xcc, 0x76, 0x1d, 0xdc, 0x85, 0x1c, 0x9b, + 0x19, 0xb7, 0x64, 0xc6, 0x41, 0x25, 0x35, 0xcb, 0x66, 0x1d, 0x32, 0xc3, 0x1d, 0xc8, 0x8e, 0xcd, + 0x01, 0x19, 0x73, 0x97, 0x05, 0x35, 0x3c, 0x48, 0x3f, 0xc3, 0xd6, 0xf5, 0x64, 0x30, 0xb6, 0xfd, + 0xdb, 0xc4, 0xc5, 0x33, 0x28, 0x7b, 0xa1, 0xc8, 0x20, 0x94, 0xba, 0xb1, 0xaf, 0x52, 0x24, 0x94, + 0x03, 0x99, 0x44, 0x01, 0x35, 0xe2, 0x58, 0xca, 0x84, 0x79, 0x13, 0xe6, 0x47, 0xd1, 0xe2, 0x01, + 0x80, 0x6f, 0x32, 0xc3, 0x23, 0xd4, 0xb8, 0x9b, 0x72, 0xbb, 0x8c, 0x9a, 0xf7, 0x4d, 0x76, 0x4d, + 0x68, 0x77, 0x8a, 0xc7, 0xb0, 0xe9, 0x86, 0xf8, 0xfa, 0xfa, 0x51, 0xe6, 0xb8, 0x78, 0x5a, 0x69, + 0x46, 0x55, 0x6d, 0xea, 0x33, 0x65, 0xc2, 0xd4, 0x58, 0xbd, 0x88, 0x35, 0x23, 0xc6, 0xfa, 0x1c, + 0x6a, 0x29, 0x9f, 0x51, 0xbc, 0xbb, 0x90, 0xa3, 0xe6, 0xd4, 0x60, 0x49, 0xbe, 0xd4, 0x9c, 0xea, + 0x33, 0xe9, 0x27, 0x40, 0xd9, 0x67, 0xf6, 0xbd, 0xc9, 0xc8, 0x05, 0x21, 0x71, 0x84, 0x87, 0x50, + 0x1c, 0xba, 0xce, 0x7b, 0x83, 0x99, 0x74, 0x44, 0xe2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b8, + 0xf4, 0x86, 0xe8, 0x41, 0x51, 0xb8, 0xaa, 0xf1, 0xa9, 0x00, 0x5d, 0x7d, 0x36, 0x34, 0xbe, 0x7a, + 0x48, 0xbd, 0x60, 0x13, 0xee, 0xe4, 0x14, 0xdb, 0xea, 0x15, 0x9f, 0x62, 0xfb, 0xdc, 0x55, 0xae, + 0x42, 0x39, 0xb5, 0xf8, 0xf1, 0xf0, 0x81, 0xc5, 0x9e, 0xc4, 0x77, 0xf4, 0x30, 0x20, 0xe2, 0xfc, + 0x1d, 0x36, 0xa3, 0xd5, 0x8a, 0x8f, 0x05, 0x70, 0xfa, 0x1a, 0x48, 0x55, 0x6c, 0x69, 0x13, 0xe3, + 0x25, 0xc0, 0x62, 0xa7, 0xe1, 0xc1, 0x03, 0xab, 0x2e, 0xe4, 0x79, 0xfa, 0xc5, 0x45, 0x88, 0x7f, + 0x41, 0x75, 0x79, 0x7f, 0xa0, 0x24, 0x9a, 0x7c, 0x7e, 0x7f, 0x35, 0x9e, 0x7d, 0x11, 0x13, 0x92, + 0x9f, 0xff, 0xf8, 0xe7, 0xc9, 0xc8, 0x66, 0xb7, 0x93, 0x41, 0x73, 0xe8, 0xde, 0x9f, 0x8c, 0x83, + 0x1b, 0xde, 0xb1, 0x9d, 0x91, 0x43, 0xd8, 0xd4, 0xa5, 0x77, 0x27, 0x63, 0xc7, 0x3a, 0xe1, 0xfb, + 0xfe, 0x24, 0xe1, 0x1a, 0xe4, 0xf8, 0x63, 0xf9, 0xe5, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb5, + 0xeb, 0x99, 0xb8, 0x75, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1181,6 +1276,12 @@ type WalletKitClient interface { //Note that these sweeps may not be confirmed yet, as we record sweeps on //broadcast, not confirmation. ListSweeps(ctx context.Context, in *ListSweepsRequest, opts ...grpc.CallOption) (*ListSweepsResponse, error) + // + //LabelTransaction adds a label to a transaction. If the transaction already + //has a label the call will fail unless the overwrite bool is set. This will + //overwrite the exiting transaction label. Labels must not be empty, and + //cannot exceed 500 characters. + LabelTransaction(ctx context.Context, in *LabelTransactionRequest, opts ...grpc.CallOption) (*LabelTransactionResponse, error) } type walletKitClient struct { @@ -1272,6 +1373,15 @@ func (c *walletKitClient) ListSweeps(ctx context.Context, in *ListSweepsRequest, return out, nil } +func (c *walletKitClient) LabelTransaction(ctx context.Context, in *LabelTransactionRequest, opts ...grpc.CallOption) (*LabelTransactionResponse, error) { + out := new(LabelTransactionResponse) + err := c.cc.Invoke(ctx, "/walletrpc.WalletKit/LabelTransaction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // WalletKitServer is the server API for WalletKit service. type WalletKitServer interface { // @@ -1344,6 +1454,12 @@ type WalletKitServer interface { //Note that these sweeps may not be confirmed yet, as we record sweeps on //broadcast, not confirmation. ListSweeps(context.Context, *ListSweepsRequest) (*ListSweepsResponse, error) + // + //LabelTransaction adds a label to a transaction. If the transaction already + //has a label the call will fail unless the overwrite bool is set. This will + //overwrite the exiting transaction label. Labels must not be empty, and + //cannot exceed 500 characters. + LabelTransaction(context.Context, *LabelTransactionRequest) (*LabelTransactionResponse, error) } func RegisterWalletKitServer(s *grpc.Server, srv WalletKitServer) { @@ -1512,6 +1628,24 @@ func _WalletKit_ListSweeps_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _WalletKit_LabelTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LabelTransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(WalletKitServer).LabelTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/walletrpc.WalletKit/LabelTransaction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(WalletKitServer).LabelTransaction(ctx, req.(*LabelTransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _WalletKit_serviceDesc = grpc.ServiceDesc{ ServiceName: "walletrpc.WalletKit", HandlerType: (*WalletKitServer)(nil), @@ -1552,6 +1686,10 @@ var _WalletKit_serviceDesc = grpc.ServiceDesc{ MethodName: "ListSweeps", Handler: _WalletKit_ListSweeps_Handler, }, + { + MethodName: "LabelTransaction", + Handler: _WalletKit_LabelTransaction_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "walletrpc/walletkit.proto", diff --git a/lnrpc/walletrpc/walletkit.proto b/lnrpc/walletrpc/walletkit.proto index 5cafbc54..a8b9cf1f 100644 --- a/lnrpc/walletrpc/walletkit.proto +++ b/lnrpc/walletrpc/walletkit.proto @@ -97,6 +97,15 @@ service WalletKit { broadcast, not confirmation. */ rpc ListSweeps (ListSweepsRequest) returns (ListSweepsResponse); + + /* + LabelTransaction adds a label to a transaction. If the transaction already + has a label the call will fail unless the overwrite bool is set. This will + overwrite the exiting transaction label. Labels must not be empty, and + cannot exceed 500 characters. + */ + rpc LabelTransaction (LabelTransactionRequest) + returns (LabelTransactionResponse); } message KeyReq { @@ -367,3 +376,17 @@ message ListSweepsResponse { TransactionIDs transaction_ids = 2; } } + +message LabelTransactionRequest { + // The txid of the transaction to label. + bytes txid = 1; + + // The label to add to the transaction, limited to 500 characters. + string label = 2; + + // Whether to overwrite the existing label, if it is present. + bool overwrite = 3; +} + +message LabelTransactionResponse { +} diff --git a/lnrpc/walletrpc/walletkit.swagger.json b/lnrpc/walletrpc/walletkit.swagger.json index 50cca827..26a2ede6 100644 --- a/lnrpc/walletrpc/walletkit.swagger.json +++ b/lnrpc/walletrpc/walletkit.swagger.json @@ -178,6 +178,9 @@ } } }, + "walletrpcLabelTransactionResponse": { + "type": "object" + }, "walletrpcListSweepsResponse": { "type": "object", "properties": { diff --git a/lnrpc/walletrpc/walletkit_server.go b/lnrpc/walletrpc/walletkit_server.go index bb021b85..f192fcbe 100644 --- a/lnrpc/walletrpc/walletkit_server.go +++ b/lnrpc/walletrpc/walletkit_server.go @@ -94,6 +94,10 @@ var ( Entity: "onchain", Action: "read", }}, + "/walletrpc.WalletKit/LabelTransaction": {{ + Entity: "onchain", + Action: "write", + }}, } // DefaultWalletKitMacFilename is the default name of the wallet kit @@ -102,6 +106,10 @@ var ( DefaultWalletKitMacFilename = "walletkit.macaroon" ) +// ErrZeroLabel is returned when an attempt is made to label a transaction with +// an empty label. +var ErrZeroLabel = errors.New("cannot label transaction with empty label") + // WalletKit is a sub-RPC server that exposes a tool kit which allows clients // to execute common wallet operations. This includes requesting new addresses, // keys (for contracts!), and publishing transactions. @@ -635,3 +643,28 @@ func (w *WalletKit) ListSweeps(ctx context.Context, }, }, nil } + +// LabelTransaction adds a label to a transaction. +func (w *WalletKit) LabelTransaction(ctx context.Context, + req *LabelTransactionRequest) (*LabelTransactionResponse, error) { + + // Check that the label provided in non-zero. + if len(req.Label) == 0 { + return nil, ErrZeroLabel + } + + // Validate the length of the non-zero label. We do not need to use the + // label returned here, because the original is non-zero so will not + // be replaced. + if _, err := labels.ValidateAPI(req.Label); err != nil { + return nil, err + } + + hash, err := chainhash.NewHash(req.Txid) + if err != nil { + return nil, err + } + + err = w.cfg.Wallet.LabelTransaction(*hash, req.Label, req.Overwrite) + return &LabelTransactionResponse{}, err +} diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 7e5083f1..701349ed 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -28,6 +28,7 @@ import ( "github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcutil" + "github.com/btcsuite/btcwallet/wallet" "github.com/davecgh/go-spew/spew" "github.com/go-errors/errors" "github.com/lightningnetwork/lnd" @@ -12652,24 +12653,66 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("expected 2 inputs instead have %v", len(sweepTx.TxIn)) } - // List all transactions relevant to our wallet, and find the sweep tx - // so that we can check the correct label has been set. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - txResp, err := ainz.GetTransactions(ctxt, &lnrpc.GetTransactionsRequest{}) - if err != nil { - t.Fatalf("could not get transactions: %v", err) + sweepTxStr := sweepTx.TxHash().String() + assertTxLabel(ctxb, t, ainz, sweepTxStr, sendCoinsLabel) + + // While we are looking at labels, we test our label transaction command + // to make sure it is behaving as expected. First, we try to label our + // transaction with an empty label, and check that we fail as expected. + sweepHash := sweepTx.TxHash() + _, err = ainz.WalletKitClient.LabelTransaction( + ctxt, &walletrpc.LabelTransactionRequest{ + Txid: sweepHash[:], + Label: "", + Overwrite: false, + }, + ) + if err == nil { + t.Fatalf("expected error for zero transaction label") } - sweepTxStr := sweepTx.TxHash().String() - for _, txn := range txResp.Transactions { - if txn.TxHash == sweepTxStr { - if txn.Label != sendCoinsLabel { - t.Fatalf("expected label: %v, got: %v", - sendCoinsLabel, txn.Label) - } - } + // Our error will be wrapped in a rpc error, so we check that it + // contains the error we expect. + if !strings.Contains(err.Error(), walletrpc.ErrZeroLabel.Error()) { + t.Fatalf("expected: zero label error, got: %v", err) } + // Next, we try to relabel our transaction without setting the overwrite + // boolean. We expect this to fail, because the wallet requires setting + // of this param to prevent accidental overwrite of labels. + _, err = ainz.WalletKitClient.LabelTransaction( + ctxt, &walletrpc.LabelTransactionRequest{ + Txid: sweepHash[:], + Label: "label that will not work", + Overwrite: false, + }, + ) + if err == nil { + t.Fatalf("expected error for tx already labelled") + } + + // Our error will be wrapped in a rpc error, so we check that it + // contains the error we expect. + if !strings.Contains(err.Error(), wallet.ErrTxLabelExists.Error()) { + t.Fatalf("expected: label exists, got: %v", err) + } + + // Finally, we overwrite our label with a new label, which should not + // fail. + newLabel := "new sweep tx label" + _, err = ainz.WalletKitClient.LabelTransaction( + ctxt, &walletrpc.LabelTransactionRequest{ + Txid: sweepHash[:], + Label: newLabel, + Overwrite: true, + }, + ) + if err != nil { + t.Fatalf("could not label tx: %v", err) + } + + assertTxLabel(ctxb, t, ainz, sweepTxStr, newLabel) + // Finally, Ainz should now have no coins at all within his wallet. balReq := &lnrpc.WalletBalanceRequest{} resp, err := ainz.WalletBalance(ctxt, balReq) @@ -12695,6 +12738,35 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) { } } +// assertTxLabel is a helper function which finds a target tx in our set +// of transactions and checks that it has the desired label. +func assertTxLabel(ctx context.Context, t *harnessTest, + node *lntest.HarnessNode, targetTx, label string) { + + // List all transactions relevant to our wallet, and find the tx so that + // we can check the correct label has been set. + ctxt, cancel := context.WithTimeout(ctx, defaultTimeout) + defer cancel() + + txResp, err := node.GetTransactions( + ctxt, &lnrpc.GetTransactionsRequest{}, + ) + if err != nil { + t.Fatalf("could not get transactions: %v", err) + } + + // Find our transaction in the set of transactions returned and check + // its label. + for _, txn := range txResp.Transactions { + if txn.TxHash == targetTx { + if txn.Label != label { + t.Fatalf("expected label: %v, got: %v", + label, txn.Label) + } + } + } +} + // testChannelBackupUpdates tests that both the streaming channel update RPC, // and the on-disk channels.backup are updated each time a channel is // opened/closed. diff --git a/lntest/itest/log_error_whitelist.txt b/lntest/itest/log_error_whitelist.txt index dbf7a48a..a65ce6ce 100644 --- a/lntest/itest/log_error_whitelist.txt +++ b/lntest/itest/log_error_whitelist.txt @@ -179,3 +179,5 @@