BroadcastRBF -> BroadcastReplacement

This commit is contained in:
Ori Newman 2024-09-13 13:45:06 +03:00
parent 0c51953dc1
commit 470b9c7e6e
8 changed files with 51 additions and 130 deletions

View File

@ -42,7 +42,7 @@ func broadcastReplacement(conf *broadcastConfig) error {
return err return err
} }
response, err := daemonClient.BroadcastRBF(ctx, &pb.BroadcastRequest{Transactions: transactions}) response, err := daemonClient.BroadcastReplacement(ctx, &pb.BroadcastRequest{Transactions: transactions})
if err != nil { if err != nil {
return err return err
} }

View File

@ -88,7 +88,7 @@ func bumpFee(conf *bumpFeeConfig) error {
} }
chunk := signedTransactions[offset:end] chunk := signedTransactions[offset:end]
response, err := daemonClient.BroadcastRBF(broadcastCtx, &pb.BroadcastRequest{Transactions: chunk}) response, err := daemonClient.BroadcastReplacement(broadcastCtx, &pb.BroadcastRequest{Transactions: chunk})
if err != nil { if err != nil {
return err return err
} }

View File

@ -1719,7 +1719,7 @@ var file_kaspawalletd_proto_rawDesc = []byte{
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e,
0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x78, 0x49, 0x44,
0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x32, 0xa3, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x32, 0xab,
0x08, 0x0a, 0x0c, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x12, 0x08, 0x0a, 0x0c, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x12,
0x51, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x2e, 0x51, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x2e,
0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x47, 0x65, 0x74,
@ -1763,34 +1763,34 @@ var file_kaspawalletd_proto_rawDesc = []byte{
0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x1f, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x42, 0x1f, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x42,
0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x51, 0x0a, 0x0c, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x22, 0x00, 0x12, 0x59, 0x0a, 0x14, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52,
0x42, 0x46, 0x12, 0x1e, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x2e, 0x6b, 0x61, 0x73,
0x64, 0x2e, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63,
0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x61, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6b, 0x61, 0x73,
0x64, 0x2e, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x04, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x19, 0x2e, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3f, 0x0a,
0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x53, 0x65, 0x6e, 0x04, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x19, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c,
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x1a, 0x1a, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x04, 0x53, 0x69, 0x67, 0x6e, 0x12, 0x19, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3f,
0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x53, 0x69, 0x0a, 0x04, 0x53, 0x69, 0x67, 0x6e, 0x12, 0x19, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61,
0x67, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x51, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x56, 0x65, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x51, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e,
0x6c, 0x65, 0x74, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x47, 0x65, 0x74,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20,
0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x47, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x07, 0x42, 0x75, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x6d, 0x70, 0x46, 0x65, 0x65, 0x12, 0x1c, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x07, 0x42, 0x75, 0x6d, 0x70, 0x46, 0x65, 0x65, 0x12, 0x1c, 0x2e,
0x6c, 0x65, 0x74, 0x64, 0x2e, 0x42, 0x75, 0x6d, 0x70, 0x46, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x42, 0x75, 0x6d,
0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x70, 0x46, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6b, 0x61,
0x74, 0x64, 0x2e, 0x42, 0x75, 0x6d, 0x70, 0x46, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2e, 0x42, 0x75, 0x6d, 0x70, 0x46,
0x73, 0x65, 0x22, 0x00, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x36, 0x5a, 0x34,
0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61,
0x61, 0x64, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x6b,
0x65, 0x74, 0x2f, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x61, 0x73, 0x70, 0x61, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x2f, 0x64, 0x61, 0x65, 0x6d, 0x6f,
0x6f, 0x74, 0x6f, 0x33, 0x6e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -1852,7 +1852,7 @@ var file_kaspawalletd_proto_depIdxs = []int32{
8, // 12: kaspawalletd.kaspawalletd.NewAddress:input_type -> kaspawalletd.NewAddressRequest 8, // 12: kaspawalletd.kaspawalletd.NewAddress:input_type -> kaspawalletd.NewAddressRequest
12, // 13: kaspawalletd.kaspawalletd.Shutdown:input_type -> kaspawalletd.ShutdownRequest 12, // 13: kaspawalletd.kaspawalletd.Shutdown:input_type -> kaspawalletd.ShutdownRequest
10, // 14: kaspawalletd.kaspawalletd.Broadcast:input_type -> kaspawalletd.BroadcastRequest 10, // 14: kaspawalletd.kaspawalletd.Broadcast:input_type -> kaspawalletd.BroadcastRequest
10, // 15: kaspawalletd.kaspawalletd.BroadcastRBF:input_type -> kaspawalletd.BroadcastRequest 10, // 15: kaspawalletd.kaspawalletd.BroadcastReplacement:input_type -> kaspawalletd.BroadcastRequest
20, // 16: kaspawalletd.kaspawalletd.Send:input_type -> kaspawalletd.SendRequest 20, // 16: kaspawalletd.kaspawalletd.Send:input_type -> kaspawalletd.SendRequest
22, // 17: kaspawalletd.kaspawalletd.Sign:input_type -> kaspawalletd.SignRequest 22, // 17: kaspawalletd.kaspawalletd.Sign:input_type -> kaspawalletd.SignRequest
24, // 18: kaspawalletd.kaspawalletd.GetVersion:input_type -> kaspawalletd.GetVersionRequest 24, // 18: kaspawalletd.kaspawalletd.GetVersion:input_type -> kaspawalletd.GetVersionRequest
@ -1864,7 +1864,7 @@ var file_kaspawalletd_proto_depIdxs = []int32{
9, // 24: kaspawalletd.kaspawalletd.NewAddress:output_type -> kaspawalletd.NewAddressResponse 9, // 24: kaspawalletd.kaspawalletd.NewAddress:output_type -> kaspawalletd.NewAddressResponse
13, // 25: kaspawalletd.kaspawalletd.Shutdown:output_type -> kaspawalletd.ShutdownResponse 13, // 25: kaspawalletd.kaspawalletd.Shutdown:output_type -> kaspawalletd.ShutdownResponse
11, // 26: kaspawalletd.kaspawalletd.Broadcast:output_type -> kaspawalletd.BroadcastResponse 11, // 26: kaspawalletd.kaspawalletd.Broadcast:output_type -> kaspawalletd.BroadcastResponse
11, // 27: kaspawalletd.kaspawalletd.BroadcastRBF:output_type -> kaspawalletd.BroadcastResponse 11, // 27: kaspawalletd.kaspawalletd.BroadcastReplacement:output_type -> kaspawalletd.BroadcastResponse
21, // 28: kaspawalletd.kaspawalletd.Send:output_type -> kaspawalletd.SendResponse 21, // 28: kaspawalletd.kaspawalletd.Send:output_type -> kaspawalletd.SendResponse
23, // 29: kaspawalletd.kaspawalletd.Sign:output_type -> kaspawalletd.SignResponse 23, // 29: kaspawalletd.kaspawalletd.Sign:output_type -> kaspawalletd.SignResponse
25, // 30: kaspawalletd.kaspawalletd.GetVersion:output_type -> kaspawalletd.GetVersionResponse 25, // 30: kaspawalletd.kaspawalletd.GetVersion:output_type -> kaspawalletd.GetVersionResponse

View File

@ -13,8 +13,8 @@ service kaspawalletd {
rpc NewAddress(NewAddressRequest) returns (NewAddressResponse) {} rpc NewAddress(NewAddressRequest) returns (NewAddressResponse) {}
rpc Shutdown(ShutdownRequest) returns (ShutdownResponse) {} rpc Shutdown(ShutdownRequest) returns (ShutdownResponse) {}
rpc Broadcast(BroadcastRequest) returns (BroadcastResponse) {} rpc Broadcast(BroadcastRequest) returns (BroadcastResponse) {}
// BroadcastRBF assumes that all transactions depend on the first one // BroadcastReplacement assumes that all transactions depend on the first one
rpc BroadcastRBF(BroadcastRequest) returns (BroadcastResponse) {} rpc BroadcastReplacement(BroadcastRequest) returns (BroadcastResponse) {}
// Since SendRequest contains a password - this command should only be used on // Since SendRequest contains a password - this command should only be used on
// a trusted or secure connection // a trusted or secure connection
rpc Send(SendRequest) returns (SendResponse) {} rpc Send(SendRequest) returns (SendResponse) {}

View File

@ -29,7 +29,8 @@ type KaspawalletdClient interface {
NewAddress(ctx context.Context, in *NewAddressRequest, opts ...grpc.CallOption) (*NewAddressResponse, error) NewAddress(ctx context.Context, in *NewAddressRequest, opts ...grpc.CallOption) (*NewAddressResponse, error)
Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownResponse, error) Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownResponse, error)
Broadcast(ctx context.Context, in *BroadcastRequest, opts ...grpc.CallOption) (*BroadcastResponse, error) Broadcast(ctx context.Context, in *BroadcastRequest, opts ...grpc.CallOption) (*BroadcastResponse, error)
BroadcastRBF(ctx context.Context, in *BroadcastRequest, opts ...grpc.CallOption) (*BroadcastResponse, error) // BroadcastReplacement assumes that all transactions depend on the first one
BroadcastReplacement(ctx context.Context, in *BroadcastRequest, opts ...grpc.CallOption) (*BroadcastResponse, error)
// Since SendRequest contains a password - this command should only be used on // Since SendRequest contains a password - this command should only be used on
// a trusted or secure connection // a trusted or secure connection
Send(ctx context.Context, in *SendRequest, opts ...grpc.CallOption) (*SendResponse, error) Send(ctx context.Context, in *SendRequest, opts ...grpc.CallOption) (*SendResponse, error)
@ -111,9 +112,9 @@ func (c *kaspawalletdClient) Broadcast(ctx context.Context, in *BroadcastRequest
return out, nil return out, nil
} }
func (c *kaspawalletdClient) BroadcastRBF(ctx context.Context, in *BroadcastRequest, opts ...grpc.CallOption) (*BroadcastResponse, error) { func (c *kaspawalletdClient) BroadcastReplacement(ctx context.Context, in *BroadcastRequest, opts ...grpc.CallOption) (*BroadcastResponse, error) {
out := new(BroadcastResponse) out := new(BroadcastResponse)
err := c.cc.Invoke(ctx, "/kaspawalletd.kaspawalletd/BroadcastRBF", in, out, opts...) err := c.cc.Invoke(ctx, "/kaspawalletd.kaspawalletd/BroadcastReplacement", in, out, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -167,7 +168,8 @@ type KaspawalletdServer interface {
NewAddress(context.Context, *NewAddressRequest) (*NewAddressResponse, error) NewAddress(context.Context, *NewAddressRequest) (*NewAddressResponse, error)
Shutdown(context.Context, *ShutdownRequest) (*ShutdownResponse, error) Shutdown(context.Context, *ShutdownRequest) (*ShutdownResponse, error)
Broadcast(context.Context, *BroadcastRequest) (*BroadcastResponse, error) Broadcast(context.Context, *BroadcastRequest) (*BroadcastResponse, error)
BroadcastRBF(context.Context, *BroadcastRequest) (*BroadcastResponse, error) // BroadcastReplacement assumes that all transactions depend on the first one
BroadcastReplacement(context.Context, *BroadcastRequest) (*BroadcastResponse, error)
// Since SendRequest contains a password - this command should only be used on // Since SendRequest contains a password - this command should only be used on
// a trusted or secure connection // a trusted or secure connection
Send(context.Context, *SendRequest) (*SendResponse, error) Send(context.Context, *SendRequest) (*SendResponse, error)
@ -204,8 +206,8 @@ func (UnimplementedKaspawalletdServer) Shutdown(context.Context, *ShutdownReques
func (UnimplementedKaspawalletdServer) Broadcast(context.Context, *BroadcastRequest) (*BroadcastResponse, error) { func (UnimplementedKaspawalletdServer) Broadcast(context.Context, *BroadcastRequest) (*BroadcastResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Broadcast not implemented") return nil, status.Errorf(codes.Unimplemented, "method Broadcast not implemented")
} }
func (UnimplementedKaspawalletdServer) BroadcastRBF(context.Context, *BroadcastRequest) (*BroadcastResponse, error) { func (UnimplementedKaspawalletdServer) BroadcastReplacement(context.Context, *BroadcastRequest) (*BroadcastResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method BroadcastRBF not implemented") return nil, status.Errorf(codes.Unimplemented, "method BroadcastReplacement not implemented")
} }
func (UnimplementedKaspawalletdServer) Send(context.Context, *SendRequest) (*SendResponse, error) { func (UnimplementedKaspawalletdServer) Send(context.Context, *SendRequest) (*SendResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Send not implemented") return nil, status.Errorf(codes.Unimplemented, "method Send not implemented")
@ -358,20 +360,20 @@ func _Kaspawalletd_Broadcast_Handler(srv interface{}, ctx context.Context, dec f
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Kaspawalletd_BroadcastRBF_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _Kaspawalletd_BroadcastReplacement_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(BroadcastRequest) in := new(BroadcastRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(KaspawalletdServer).BroadcastRBF(ctx, in) return srv.(KaspawalletdServer).BroadcastReplacement(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/kaspawalletd.kaspawalletd/BroadcastRBF", FullMethod: "/kaspawalletd.kaspawalletd/BroadcastReplacement",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(KaspawalletdServer).BroadcastRBF(ctx, req.(*BroadcastRequest)) return srv.(KaspawalletdServer).BroadcastReplacement(ctx, req.(*BroadcastRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
@ -484,8 +486,8 @@ var Kaspawalletd_ServiceDesc = grpc.ServiceDesc{
Handler: _Kaspawalletd_Broadcast_Handler, Handler: _Kaspawalletd_Broadcast_Handler,
}, },
{ {
MethodName: "BroadcastRBF", MethodName: "BroadcastReplacement",
Handler: _Kaspawalletd_BroadcastRBF_Handler, Handler: _Kaspawalletd_BroadcastReplacement_Handler,
}, },
{ {
MethodName: "Send", MethodName: "Send",

View File

@ -1,81 +0,0 @@
package server
import (
"context"
"time"
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
"github.com/kaspanet/kaspad/cmd/kaspawallet/libkaspawallet"
"github.com/kaspanet/kaspad/cmd/kaspawallet/libkaspawallet/serialization"
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
"github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing"
"github.com/kaspanet/kaspad/infrastructure/network/rpcclient"
"github.com/pkg/errors"
)
func (s *server) BroadcastRBF(_ context.Context, request *pb.BroadcastRequest) (*pb.BroadcastResponse, error) {
s.lock.Lock()
defer s.lock.Unlock()
txIDs, err := s.broadcastRBF(request.Transactions, request.IsDomain)
if err != nil {
return nil, err
}
return &pb.BroadcastResponse{TxIDs: txIDs}, nil
}
// broadcastRBF assumes that all transactions depend on the first one
func (s *server) broadcastRBF(transactions [][]byte, isDomain bool) ([]string, error) {
txIDs := make([]string, len(transactions))
var tx *externalapi.DomainTransaction
var err error
for i, transaction := range transactions {
if isDomain {
tx, err = serialization.DeserializeDomainTransaction(transaction)
if err != nil {
return nil, err
}
} else if !isDomain { //default in proto3 is false
tx, err = libkaspawallet.ExtractTransaction(transaction, s.keysFile.ECDSA)
if err != nil {
return nil, err
}
}
// Once the first transaction is added to the mempool, the transactions that depend
// on the replaced transaction will be removed, so there's no need to submit them
// as RBF transactions.
if i == 0 {
txIDs[i], err = sendTransactionRBF(s.rpcClient, tx)
if err != nil {
return nil, err
}
} else {
txIDs[i], err = sendTransaction(s.rpcClient, tx)
if err != nil {
return nil, err
}
}
for _, input := range tx.Inputs {
s.usedOutpoints[input.PreviousOutpoint] = time.Now()
}
}
s.forceSync()
return txIDs, nil
}
func sendTransactionRBF(client *rpcclient.RPCClient, tx *externalapi.DomainTransaction) (string, error) {
submitTransactionResponse, err := client.SubmitTransactionReplacement(appmessage.DomainTransactionToRPCTransaction(tx), consensushashing.TransactionID(tx).String())
if err != nil {
return "", errors.Wrapf(err, "error submitting transaction replacement")
}
return submitTransactionResponse.TransactionID, nil
}

View File

@ -144,7 +144,7 @@ func (s *server) BumpFee(_ context.Context, request *pb.BumpFeeRequest) (*pb.Bum
return nil, err return nil, err
} }
txIDs, err := s.broadcastRBF(signedTransactions, false) txIDs, err := s.broadcastReplacement(signedTransactions, false)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -17,7 +17,7 @@ const (
// appBuild is defined as a variable so it can be overridden during the build // appBuild is defined as a variable so it can be overridden during the build
// process with '-ldflags "-X github.com/kaspanet/kaspad/version.appBuild=foo"' if needed. // process with '-ldflags "-X github.com/kaspanet/kaspad/version.appBuild=foo"' if needed.
// It MUST only contain characters from validCharacters. // It MUST only contain characters from validCharacters.
var appBuild string = "rc1" var appBuild string = "rc2"
var version = "" // string used for memoization of version var version = "" // string used for memoization of version