Skip to content

api spec#1

Closed
sekulicd wants to merge 2 commits intovulpemventures:masterfrom
sekulicd:api-spec
Closed

api spec#1
sekulicd wants to merge 2 commits intovulpemventures:masterfrom
sekulicd:api-spec

Conversation

@sekulicd
Copy link
Contributor

This adds api spec of the wallet daemon.
Purpose of a daemon is to run as a sidecar for other applications and removes 'heavy burden' of maintaining internal wallet.
Protobuf files are splitted into 4 files that I see as main features of the wallet.
Wallet -> covers creation/restore of wallet
Account -> covers creation on addresses, tracking balance and uspents for specific account
Transaction -> used for crafting various types of transactions
Notification -> defines rpc's that are to be used for fetching notification.

@tiero @altafan please review.

@tiero tiero requested a review from altafan December 28, 2021 12:54
Makefile Outdated
.PHONY: proto doc

## proto: compile proto files
proto:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we start with buf.build?

int64 account_index = 1;
}

message UpdateRequest{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only to update the name? not changes to derivations?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to specify in the comment then (since we generate doc from it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done__

Comment on lines +140 to +143
// Asset in bytes or asset_commitment if value is blinded
bytes asset = 3;
// Value in bytes or value_commitment if value is blinded
bytes value = 4;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to have a dedicate field for each, when blinded we leave this empty, when unblinded we should return both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

uint64 target_amount = 3;
// Unspents selection algorithm.
enum Strategy {
RANDOM = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RANDOM = 0;
BRANCH_BOUND = 0;
FRAGMENT =1;

the onw

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +77 to +79
bytes asset = 3;
// Value in bytes or value_commitment if value is blinded
bytes value = 4;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@tiero
Copy link
Member

tiero commented Dec 28, 2021

Just to keep in mind, Conceptually we can load the wallet also in a watch-only mode ie. no signing keys on board, only xpub(s) and master blinding key.

Maybe an RPC in Wallet service that gives us this info could be helpful

Open is used to open existing HD Wallet based on password so that daemon can serve
other calls
*/
rpc Open (OpenRequest) returns (OpenResponse);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rpc Open (OpenRequest) returns (OpenResponse);
rpc Unlock (OpenRequest) returns (OpenResponse);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +46 to +55
message CreateRequest{
// signing_mnemonic is 24 length phrase used to derive addresses and scripts
string signing_mnemonic = 1;

// blinding_mnemonic is 24 length phrase used to derive blinding keys
string blinding_mnemonic = 2;

// password is used to encrypt HD Wallet wallet. After creation, password is required to unlock the wallet daemon.
bytes password = 3;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should specify the derivation path here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about descriptor?

Copy link
Member

@tiero tiero Dec 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think should instead be under Account, and be a dedicate RPC: ideally CreateAccount derives new xpub, with that result we pass it to compose our descriptor/miniscript/ionio in a second UpdateScriptTemplate kind of.

}
message CreateAccountReply{
// Account index of the derivation path.
int64 account_index = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the resulting xpub for the account here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the derivation path of the xpub for completeness?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

AccountKey account_key = 1;
// Name of the account to be updated.
string name = 2;
}
Copy link
Member

@tiero tiero Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add here a Template template field, to accept descriptor, miniscript, ionio, raw opcode templates etc..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +71 to +75
enum Type {
P2WPKH = 0;
P2TR = 1;
}
Type type = 3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace Type with template field

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// list of unspents
repeated Unspent unspents = 2;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message Template {
  enum Format {
    DESCRIPTOR = 0,
    MINISCRIPT = 1,
    IONIO = 2,
    RAW =3
  }
  Format format = 1;
  string value;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

@altafan altafan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreatePsbt, Mint, ReMint, Burn, Transfer and ClaimPegin, they all suppose the service to use or select utxos to be used as inputs of a transaction.

Shall all these utxos be marked as locked until the tx is not detected as broadcasted or unconfirmed to prevent the wallet from using them for other requests in the meantime?

Seed is used to generate signing and blinding seed that are to be passed
to Create rpc which will create HD Wallet
*/
rpc Seed(SeedRequest) returns (SeedReply);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GenSeed more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +39 to +42
string signing_mnemonic = 1;

// blinding_mnemonic is 24 length phrase used to derive blinding keys
string blinding_mnemonic = 2;
Copy link
Collaborator

@altafan altafan Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't these be fields of the reply?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

rpc Seed(SeedRequest) returns (SeedReply);

// CreateWallet is used to create HD Wallet based on signing, blinding seeds and password
rpc CreateWallet(CreateWalletRequest) returns (CreateWalletResponse);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convenience is to use Reply suffix for returned messages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

rpc ChangePassword (ChangePasswordRequest) returns (ChangePasswordResponse);

// Restore is used to restore HD Wallet based on signing and blinding seeds
rpc Restore (RestoreRequest) returns (RestoreResponse);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name should be RestoreWallet to be consistent with CreateWallet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +19 to +20
// Tx id of the unspent
string tx_id = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Tx id of the unspent
string tx_id = 1;
// Txid of the unspent
string txid = 1;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
message CreateAccountReply{
// Account index of the derivation path.
int64 account_index = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the derivation path of the xpub for completeness?

// list of account's
repeated AccountInfo accounts = 1;
}
message AccountInfo {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing xpub and derivation path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

repeated Unspent unspents = 2;
}

message Unspent {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing field for status (un)confirmed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe missing a field for status (un)locked?

// Value commitment, empty if value is not confidential
bytes value_commitment = 6;
// Script
bytes script = 7;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would also add a string field for the address to easily get the related singing/blinding info if needed.

Comment on lines +117 to +118
// Unspents grouped by address
map<string, Unspents> unspents = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe grouping unspents based on their (un)confirmed status would make more sense?

What about those unspents used for example in a not yet broadcasted Mint tx (ins are automatically selected by the service)?
Should they be recognized as "locked"?
If yes, should they be returned here?
If yes, then we should group all unspents based on their (un)confirmed or locked status.

@sekulicd sekulicd mentioned this pull request Dec 31, 2021
@tiero tiero closed this Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants