Skip to content

Commit

Permalink
multi: add RemoveUTXOLease RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Aug 14, 2023
1 parent 61bab67 commit 2691375
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 79 deletions.
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ type Config struct {

AssetWallet tapfreighter.Wallet

CoinSelect *tapfreighter.CoinSelect

ChainPorter tapfreighter.Porter

BaseUniverse *universe.MintingArchive
Expand Down
4 changes: 4 additions & 0 deletions perms/perms.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ var (
Entity: "assets",
Action: "read",
}},
"/assetwalletrpc.AssetWallet/RemoveUTXOLease": {{
Entity: "assets",
Action: "write",
}},
"/mintrpc.Mint/MintAsset": {{
Entity: "mint",
Action: "write",
Expand Down
28 changes: 28 additions & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3335,3 +3335,31 @@ func (r *rpcServer) QueryEvents(ctx context.Context,

return rpcStats, nil
}

// RemoveUTXOLease removes the lease/lock/reservation of the given managed
// UTXO.
func (r *rpcServer) RemoveUTXOLease(ctx context.Context,
in *wrpc.RemoveUTXOLeaseRequest) (*wrpc.RemoveUTXOLeaseResponse,
error) {

if in.Outpoint == nil {
return nil, fmt.Errorf("outpoint must be specified")
}

hash, err := chainhash.NewHash(in.Outpoint.Txid)
if err != nil {
return nil, fmt.Errorf("error parsing txid: %w", err)
}

outPoint := wire.OutPoint{
Hash: *hash,
Index: in.Outpoint.OutputIndex,
}

err = r.cfg.CoinSelect.ReleaseCoins(ctx, outPoint)
if err != nil {
return nil, err
}

return &wrpc.RemoveUTXOLeaseResponse{}, nil
}
1 change: 1 addition & 0 deletions tapcfg/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
AddrBook: addrBook,
ProofArchive: proofArchive,
AssetWallet: assetWallet,
CoinSelect: coinSelect,
ChainPorter: tapfreighter.NewChainPorter(
&tapfreighter.ChainPorterConfig{
Signer: virtualTxSigner,
Expand Down
286 changes: 207 additions & 79 deletions taprpc/assetwalletrpc/assetwallet.pb.go

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions taprpc/assetwalletrpc/assetwallet.pb.json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions taprpc/assetwalletrpc/assetwallet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ service AssetWallet {
*/
rpc VerifyAssetOwnership (VerifyAssetOwnershipRequest)
returns (VerifyAssetOwnershipResponse);

/*
RemoveUTXOLease removes the lease/lock/reservation of the given managed
UTXO.
*/
rpc RemoveUTXOLease (RemoveUTXOLeaseRequest)
returns (RemoveUTXOLeaseResponse);
}

message FundVirtualPsbtRequest {
Expand Down Expand Up @@ -206,3 +213,11 @@ message VerifyAssetOwnershipRequest {
message VerifyAssetOwnershipResponse {
bool valid_proof = 1;
}

message RemoveUTXOLeaseRequest {
// The outpoint of the UTXO to remove the lease for.
OutPoint outpoint = 1;
}

message RemoveUTXOLeaseResponse {
}
3 changes: 3 additions & 0 deletions taprpc/assetwalletrpc/assetwallet.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@
}
}
},
"assetwalletrpcRemoveUTXOLeaseResponse": {
"type": "object"
},
"assetwalletrpcSignVirtualPsbtRequest": {
"type": "object",
"properties": {
Expand Down
40 changes: 40 additions & 0 deletions taprpc/assetwalletrpc/assetwallet_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2691375

Please sign in to comment.