Skip to content

Commit 437c6a5

Browse files
louisingeraltafan
andcommitted
Replace boarding descriptor with boarding exit delay (#501)
* replace boarding descriptor by boarding exit delay * fix wasm --------- Co-authored-by: altafan <[email protected]>
1 parent 5007f8c commit 437c6a5

File tree

20 files changed

+129
-30
lines changed

20 files changed

+129
-30
lines changed

api-spec/openapi/swagger/ark/v1/service.swagger.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,10 @@
531531
"type": "string",
532532
"format": "int64"
533533
},
534+
"boardingExitDelay": {
535+
"type": "string",
536+
"format": "int64"
537+
},
534538
"boardingDescriptorTemplate": {
535539
"type": "string"
536540
},

api-spec/protobuf/ark/v1/service.proto

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,16 @@ message GetInfoResponse {
9999
int64 round_interval = 4;
100100
string network = 5;
101101
int64 dust = 6;
102-
string boarding_descriptor_template = 7;
103-
repeated string vtxo_descriptor_templates = 8;
104-
string forfeit_address = 9;
105-
MarketHour market_hour = 10;
106-
string version = 11;
107-
int64 utxo_min_amount = 12; // -1 means native dust limit (default)
108-
int64 utxo_max_amount = 13; // -1 means no limit (default), 0 means boarding not allowed
109-
int64 vtxo_min_amount = 14; // -1 means native dust limit (default)
110-
int64 vtxo_max_amount = 15; // -1 means no limit (default)
102+
int64 boarding_exit_delay = 7;
103+
string boarding_descriptor_template = 8;
104+
repeated string vtxo_descriptor_templates = 9;
105+
string forfeit_address = 10;
106+
MarketHour market_hour = 11;
107+
string version = 12;
108+
int64 utxo_min_amount = 13; // -1 means native dust limit (default)
109+
int64 utxo_max_amount = 14; // -1 means no limit (default), 0 means boarding not allowed
110+
int64 vtxo_min_amount = 15; // -1 means native dust limit (default)
111+
int64 vtxo_max_amount = 16; // -1 means no limit (default)
111112
}
112113

113114
message GetBoardingAddressRequest {

api-spec/protobuf/gen/ark/v1/service.pb.go

Lines changed: 31 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ func config(ctx *cli.Context) error {
278278
"vtxo_tree_expiry": cfgData.VtxoTreeExpiry,
279279
"unilateral_exit_delay": cfgData.UnilateralExitDelay,
280280
"dust": cfgData.Dust,
281+
"boarding_exit_delay": cfgData.BoardingExitDelay,
281282
"boarding_descriptor_template": cfgData.BoardingDescriptorTemplate,
282283
"explorer_url": cfgData.ExplorerURL,
283284
"forfeit_address": cfgData.ForfeitAddress,

pkg/client-sdk/client.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ func (a *arkClient) initWithWallet(
238238
unilateralExitDelayType = common.LocktimeTypeSecond
239239
}
240240

241+
boardingExitDelayType := common.LocktimeTypeBlock
242+
if info.BoardingExitDelay >= 512 {
243+
boardingExitDelayType = common.LocktimeTypeSecond
244+
}
245+
241246
storeData := types.Config{
242247
ServerUrl: args.ServerUrl,
243248
ServerPubKey: serverPubkey,
@@ -248,6 +253,7 @@ func (a *arkClient) initWithWallet(
248253
RoundInterval: info.RoundInterval,
249254
UnilateralExitDelay: common.RelativeLocktime{Type: unilateralExitDelayType, Value: uint32(info.UnilateralExitDelay)},
250255
Dust: info.Dust,
256+
BoardingExitDelay: common.RelativeLocktime{Type: boardingExitDelayType, Value: uint32(info.BoardingExitDelay)},
251257
BoardingDescriptorTemplate: info.BoardingDescriptorTemplate,
252258
ForfeitAddress: info.ForfeitAddress,
253259
WithTransactionFeed: args.WithTransactionFeed,
@@ -324,6 +330,11 @@ func (a *arkClient) init(
324330
unilateralExitDelayType = common.LocktimeTypeSecond
325331
}
326332

333+
boardingExitDelayType := common.LocktimeTypeBlock
334+
if info.BoardingExitDelay >= 512 {
335+
boardingExitDelayType = common.LocktimeTypeSecond
336+
}
337+
327338
cfgData := types.Config{
328339
ServerUrl: args.ServerUrl,
329340
ServerPubKey: serverPubkey,
@@ -334,6 +345,7 @@ func (a *arkClient) init(
334345
RoundInterval: info.RoundInterval,
335346
UnilateralExitDelay: common.RelativeLocktime{Type: unilateralExitDelayType, Value: uint32(info.UnilateralExitDelay)},
336347
Dust: info.Dust,
348+
BoardingExitDelay: common.RelativeLocktime{Type: boardingExitDelayType, Value: uint32(info.BoardingExitDelay)},
337349
BoardingDescriptorTemplate: info.BoardingDescriptorTemplate,
338350
ExplorerURL: explorerSvc.BaseUrl(),
339351
ForfeitAddress: info.ForfeitAddress,

pkg/client-sdk/client/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type Info struct {
7272
RoundInterval int64
7373
Network string
7474
Dust uint64
75+
BoardingExitDelay int64
7576
BoardingDescriptorTemplate string
7677
ForfeitAddress string
7778
MarketHourStartTime int64

pkg/client-sdk/client/grpc/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func (a *grpcClient) GetInfo(ctx context.Context) (*client.Info, error) {
7474
Network: resp.GetNetwork(),
7575
Dust: uint64(resp.GetDust()),
7676
BoardingDescriptorTemplate: resp.GetBoardingDescriptorTemplate(),
77+
BoardingExitDelay: resp.GetBoardingExitDelay(),
7778
ForfeitAddress: resp.GetForfeitAddress(),
7879
Version: resp.GetVersion(),
7980
MarketHourStartTime: resp.GetMarketHour().GetNextStartTime(),

pkg/client-sdk/client/rest/client.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ func (a *restClient) GetInfo(
7171
if err != nil {
7272
return nil, err
7373
}
74+
75+
boardingExitDelay, err := strconv.Atoi(resp.Payload.BoardingExitDelay)
76+
if err != nil {
77+
return nil, err
78+
}
79+
7480
roundInterval, err := strconv.Atoi(resp.Payload.RoundInterval)
7581
if err != nil {
7682
return nil, err
@@ -119,6 +125,7 @@ func (a *restClient) GetInfo(
119125
RoundInterval: int64(roundInterval),
120126
Network: resp.Payload.Network,
121127
Dust: uint64(dust),
128+
BoardingExitDelay: int64(boardingExitDelay),
122129
BoardingDescriptorTemplate: resp.Payload.BoardingDescriptorTemplate,
123130
ForfeitAddress: resp.Payload.ForfeitAddress,
124131
Version: resp.Payload.Version,

pkg/client-sdk/client/rest/service/models/v1_get_info_response.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client-sdk/store/file/config_store.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (s *configStore) AddData(ctx context.Context, data types.Config) error {
6060
VtxoTreeExpiry: fmt.Sprintf("%d", data.VtxoTreeExpiry.Value),
6161
RoundInterval: fmt.Sprintf("%d", data.RoundInterval),
6262
UnilateralExitDelay: fmt.Sprintf("%d", data.UnilateralExitDelay.Value),
63+
BoardingExitDelay: fmt.Sprintf("%d", data.BoardingExitDelay.Value),
6364
Dust: fmt.Sprintf("%d", data.Dust),
6465
BoardingDescriptorTemplate: data.BoardingDescriptorTemplate,
6566
ExplorerURL: data.ExplorerURL,

pkg/client-sdk/store/file/types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type storeData struct {
2020
RoundInterval string `json:"round_interval"`
2121
UnilateralExitDelay string `json:"unilateral_exit_delay"`
2222
Dust string `json:"dust"`
23+
BoardingExitDelay string `json:"boarding_exit_delay"`
2324
BoardingDescriptorTemplate string `json:"boarding_descriptor_template"`
2425
ExplorerURL string `json:"explorer_url"`
2526
ForfeitAddress string `json:"forfeit_address"`
@@ -48,6 +49,7 @@ func (d storeData) decode() types.Config {
4849
vtxoTreeExpiry, _ := strconv.Atoi(d.VtxoTreeExpiry)
4950
roundInterval, _ := strconv.Atoi(d.RoundInterval)
5051
unilateralExitDelay, _ := strconv.Atoi(d.UnilateralExitDelay)
52+
boardingExitDelay, _ := strconv.Atoi(d.BoardingExitDelay)
5153
withTransactionFeed, _ := strconv.ParseBool(d.WithTransactionFeed)
5254
dust, _ := strconv.Atoi(d.Dust)
5355
buf, _ := hex.DecodeString(d.ServerPubKey)
@@ -72,6 +74,11 @@ func (d storeData) decode() types.Config {
7274
unilateralExitDelayType = common.LocktimeTypeSecond
7375
}
7476

77+
boardingExitDelayType := common.LocktimeTypeBlock
78+
if boardingExitDelay >= 512 {
79+
boardingExitDelayType = common.LocktimeTypeSecond
80+
}
81+
7582
return types.Config{
7683
ServerUrl: d.ServerUrl,
7784
ServerPubKey: serverPubkey,
@@ -82,6 +89,7 @@ func (d storeData) decode() types.Config {
8289
UnilateralExitDelay: common.RelativeLocktime{Type: unilateralExitDelayType, Value: uint32(unilateralExitDelay)},
8390
RoundInterval: int64(roundInterval),
8491
Dust: uint64(dust),
92+
BoardingExitDelay: common.RelativeLocktime{Type: boardingExitDelayType, Value: uint32(boardingExitDelay)},
8593
BoardingDescriptorTemplate: d.BoardingDescriptorTemplate,
8694
ExplorerURL: explorerURL,
8795
ForfeitAddress: d.ForfeitAddress,
@@ -108,6 +116,7 @@ func (d storeData) asMap() map[string]string {
108116
"round_interval": d.RoundInterval,
109117
"unilateral_exit_delay": d.UnilateralExitDelay,
110118
"dust": d.Dust,
119+
"boarding_exit_delay": d.BoardingExitDelay,
111120
"boarding_descriptor_template": d.BoardingDescriptorTemplate,
112121
"explorer_url": d.ExplorerURL,
113122
"forfeit_address": d.ForfeitAddress,

pkg/client-sdk/store/service_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func TestStore(t *testing.T) {
3030
RoundInterval: 10,
3131
UnilateralExitDelay: common.RelativeLocktime{Type: common.LocktimeTypeSecond, Value: 512},
3232
Dust: 1000,
33+
BoardingExitDelay: common.RelativeLocktime{Type: common.LocktimeTypeSecond, Value: 512},
3334
BoardingDescriptorTemplate: "tr(0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,{ and(pk(873079a0091c9b16abd1f8c508320b07f0d50144d09ccd792ce9c915dac60465), pk(USER)), and(older(604672), pk(USER)) })",
3435
ForfeitAddress: "bcrt1qzvqj",
3536
}

pkg/client-sdk/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Config struct {
2626
RoundInterval int64
2727
UnilateralExitDelay common.RelativeLocktime
2828
Dust uint64
29+
BoardingExitDelay common.RelativeLocktime
2930
BoardingDescriptorTemplate string
3031
ExplorerURL string
3132
ForfeitAddress string

pkg/client-sdk/wallet/singlekey/bitcoin_wallet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ func (w *bitcoinWallet) getAddress(
392392
data.ServerPubKey,
393393
common.RelativeLocktime{
394394
Type: data.UnilateralExitDelay.Type,
395-
Value: data.UnilateralExitDelay.Value * 2,
395+
Value: data.BoardingExitDelay.Value,
396396
},
397397
)
398398

pkg/client-sdk/wallet/wallet_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func TestWallet(t *testing.T) {
3030
RoundInterval: 10,
3131
UnilateralExitDelay: common.RelativeLocktime{Type: common.LocktimeTypeSecond, Value: 512},
3232
Dust: 1000,
33+
BoardingExitDelay: common.RelativeLocktime{Type: common.LocktimeTypeSecond, Value: 512},
3334
BoardingDescriptorTemplate: "tr(0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,{ and(pk(873079a0091c9b16abd1f8c508320b07f0d50144d09ccd792ce9c915dac60465), pk(USER)), and(older(604672), pk(USER)) })",
3435
ForfeitAddress: "bcrt1qzvqj",
3536
}

0 commit comments

Comments
 (0)