Luke Dashjr [ARCHIVE] on Nostr: 📅 Original date posted:2020-12-23 📝 Original message:1) People should not be ...
📅 Original date posted:2020-12-23
📝 Original message:1) People should not be encouraged to write or use web browsers for their
wallet.
2) You may want to look over earlier work in this area.
On Tuesday 22 December 2020 14:43:11 monokh via bitcoin-dev wrote:
> Hi
>
> This is a first draft of a BIP we intend to submit. The main intention is
> to define a simple interface that wallets and applications can agree on
> that would cover the vast majority of use cases. This can enable writing
> bitcoin applications (e.g. time lock, multi sig) on the web that can be
> seamlessly used with any compatible wallets. We have implementations of
> such examples but I don't want to turn this thread into a promotion and
> rather focus on the spec.
>
> Appreciate input from the list. Please share if there are existing efforts,
> relevant specs or use cases.
>
> ------------------------------
>
> A wallet interface specification for bitcoin applications
>
> ## Abstract
>
> This BIP describes an API for Bitcoin wallets and applications as a
> standard.
>
> ## Summary
>
> Bitcoin wallets should expose their address derivation and signing
> functions to external applications. The interface would be expressed as
> follows in javascript:
>
> ```
> {
> // Wallet Metadata
> wallet: {
> name: 'Bitcoin Core'
> },
>
> // Request access to the wallet for the current host
> async enable: (),
>
> // Request addresses and signatures from wallet
> async request ({ method, params })
> }
> ```
>
> In the web context the interface could be exposed at the top level of a
> webpage, for example under `window.bitcoin`. However this spec does not
> intend to define any standards for how and where the interfaces should be
> exposed.
>
> ## Motivation
>
> Due to the seldom available APIs exposed by wallets, applications (web or
> otherwise) are limited in how they are able to interact. Generally only
> simple sends have been available. A more robust API that introduces other
> requests will promote richer Bitcoin applications.
>
> Additionally, wallet APIs have frequently included inconsistencies in their
> interfaces and behaviour. This has required applications to build and
> maintain a separate client for each wallet, increasing the risk of bugs and
> unintended behaviour as well as being a limiting factor for the adoption of
> usable bitcoin applications.
>
> With a standardised wallet API:
>
> - Wallets have a clear API to implement
> - Applications have a clear expectation of wallet interface and behaviour
> - Applications become agnostic to the wallet specifics, increasing choice
> for users
>
> If more wallets implement the specification, applications will be developed
> more confidently by benefiting from the wallet interoperability. This
> creates a positive feedback loop.
>
> ## Specification
>
> For simplicity, the interface is defined in the context of web applications
> running in the browser (JS) however, they are simple enough to be easily
> implemented in other contexts.
>
> ### General Rules
>
> - For sensitive functions (e.g. signing), wallet software should always
> prompt the user for confirmation
>
> ### Types
>
> **UserDeniedError**
> An error type indicating that the application's request has been denied by
> the user
> Type: Error
>
> **Hex**
> Type: String
> Example:
> `"0000000000000000000a24677957d1e50d70e67c513d220dbe8868c4c3aefc08"`
>
> **Address**
> Address details
> Type: Object
> Example:
>
> ```
> {
> "address": "bc1qn0fqlzamcfuahq6xuujrq08ex7e26agt20gexs",
> "publicKey":
> "02ad58c0dced71a236f4073c3b6f0ee27dde6fe96978e9a9c9500172e3f1886e5a",
> "derivationPath": "84'/1'/0'/0/0"
> }
> ```
>
> ### API
>
> The wallet must implement the following methods.
>
> **enable**
>
> The enable call prompts the user for access to the wallet.
>
> If successful, it resolves to an address (`**Address**` type) of the
> wallet. Typically the first external address to be used as an identity.
>
> **`UserDeniedError`** will be thrown if the request is rejected.
>
> **request**
>
> The request method must take one parameter in the following format:
>
> ```
> {
> "method": "wallet_methodName",
> "params": ["foo", "bar", "baz"]
> }
> ```
>
> For a list of mandatory methods see Table
>
> The wallet should reject request calls unless `enable` has been resolved.
>
> Sensitive requests that involve signing should always prompt the user for
> confirmation
>
> On success the request should resolve to the response as defined in the
> method table.
>
> **`UserDeniedError`** will be thrown if the request is rejected.
>
> **Mandatory methods**
>
> method: `wallet_getAddresses` params: [`index = 0, numAddresses = 1, change
> = false`]
> return: `[ Address ]`
> error: UserDeniedError
>
> method: `wallet_signMessage` params: `[ message, address ]`
> return: Signature `Hex`
> error: UserDeniedError
>
> method: `wallet_signPSBT` params: `[ [psbtBase64, inputIndex, address] ]`
> return: `psbtBase64`
> error: UserDeniedError
>
> method: `wallet_getConnectedNetwork` params: `[]`
> return: Network object `mainnet` | `testnet` | `regetst`
> error: UserDeniedError
>
> ## Rationale
>
> The purpose of the API is to expose a set of commonly used wallet
> operations. In addition, it should be flexible enough to serve for other
> requests such as node RPC calls.
>
> **Why is there a singular request call instead of named methods?**
> The transport layer for the requests cannot be assumed, therefore it is
> much more flexible to instead define an abstract format.
>
> **Why are the mandatory methods so primitive? Where is getBalance,
> getUtxos, ... ?**
> A wallet need not worry about providing every possible scenario for usage.
> The primitives of keys and signing can expose enough to applications to do
> the rest. Applications should have flexibility in how they implement these
> functions. It is the role of a library rather than the wallet.
>
> ## Security Implications
>
> Great care should be taken when exposing wallet functionality externally as
> the security and privacy of the user is at risk.
>
> ### Signing
>
> Operations that trigger signing using private keys should be guarded behind
> confirmation screens where the user is fully aware of the nature of the
> transaction. In the example of a PSBT signature request, the outputs, the
> inputs and which key is being used should be clearly marked.
>
> ### Privacy
>
> Some api methods expose metadata about the user, such as public keys.
> Depending on how privacy focused the wallet intends to be, the wallet could
> protect these behind a confirmation. Commonly the wallet just needs to give
> the origin access to all of its public keys, however it could also allow
> the option to expose only selected derivation paths.
>
> -monokh
Published at
2023-06-07 18:27:54Event JSON
{
"id": "22cfb7b5b85ac947803e84ce7e948a86c3ba351461ff3e98964a302d9d7b78e1",
"pubkey": "5a6d1f44482b67b5b0d30cc1e829b66a251f0dc99448377dbe3c5e0faf6c3803",
"created_at": 1686162474,
"kind": 1,
"tags": [
[
"e",
"2c1186c14e1810ca100c50ad6b73aefce8a2d3350bc75ce5f84f877423dc027c",
"",
"root"
],
[
"e",
"ddd31594f656418f1b0395b771d46aa1471e9099def333b5cadb49e776a66ebf",
"",
"reply"
],
[
"p",
"a8b84183add8ac22b788ca7a2f520c99193ed778ecada6fb3fc7eaf2771ca0ca"
]
],
"content": "📅 Original date posted:2020-12-23\n📝 Original message:1) People should not be encouraged to write or use web browsers for their \nwallet.\n2) You may want to look over earlier work in this area.\n\nOn Tuesday 22 December 2020 14:43:11 monokh via bitcoin-dev wrote:\n\u003e Hi\n\u003e\n\u003e This is a first draft of a BIP we intend to submit. The main intention is\n\u003e to define a simple interface that wallets and applications can agree on\n\u003e that would cover the vast majority of use cases. This can enable writing\n\u003e bitcoin applications (e.g. time lock, multi sig) on the web that can be\n\u003e seamlessly used with any compatible wallets. We have implementations of\n\u003e such examples but I don't want to turn this thread into a promotion and\n\u003e rather focus on the spec.\n\u003e\n\u003e Appreciate input from the list. Please share if there are existing efforts,\n\u003e relevant specs or use cases.\n\u003e\n\u003e ------------------------------\n\u003e\n\u003e A wallet interface specification for bitcoin applications\n\u003e\n\u003e ## Abstract\n\u003e\n\u003e This BIP describes an API for Bitcoin wallets and applications as a\n\u003e standard.\n\u003e\n\u003e ## Summary\n\u003e\n\u003e Bitcoin wallets should expose their address derivation and signing\n\u003e functions to external applications. The interface would be expressed as\n\u003e follows in javascript:\n\u003e\n\u003e ```\n\u003e {\n\u003e // Wallet Metadata\n\u003e wallet: {\n\u003e name: 'Bitcoin Core'\n\u003e },\n\u003e\n\u003e // Request access to the wallet for the current host\n\u003e async enable: (),\n\u003e\n\u003e // Request addresses and signatures from wallet\n\u003e async request ({ method, params })\n\u003e }\n\u003e ```\n\u003e\n\u003e In the web context the interface could be exposed at the top level of a\n\u003e webpage, for example under `window.bitcoin`. However this spec does not\n\u003e intend to define any standards for how and where the interfaces should be\n\u003e exposed.\n\u003e\n\u003e ## Motivation\n\u003e\n\u003e Due to the seldom available APIs exposed by wallets, applications (web or\n\u003e otherwise) are limited in how they are able to interact. Generally only\n\u003e simple sends have been available. A more robust API that introduces other\n\u003e requests will promote richer Bitcoin applications.\n\u003e\n\u003e Additionally, wallet APIs have frequently included inconsistencies in their\n\u003e interfaces and behaviour. This has required applications to build and\n\u003e maintain a separate client for each wallet, increasing the risk of bugs and\n\u003e unintended behaviour as well as being a limiting factor for the adoption of\n\u003e usable bitcoin applications.\n\u003e\n\u003e With a standardised wallet API:\n\u003e\n\u003e - Wallets have a clear API to implement\n\u003e - Applications have a clear expectation of wallet interface and behaviour\n\u003e - Applications become agnostic to the wallet specifics, increasing choice\n\u003e for users\n\u003e\n\u003e If more wallets implement the specification, applications will be developed\n\u003e more confidently by benefiting from the wallet interoperability. This\n\u003e creates a positive feedback loop.\n\u003e\n\u003e ## Specification\n\u003e\n\u003e For simplicity, the interface is defined in the context of web applications\n\u003e running in the browser (JS) however, they are simple enough to be easily\n\u003e implemented in other contexts.\n\u003e\n\u003e ### General Rules\n\u003e\n\u003e - For sensitive functions (e.g. signing), wallet software should always\n\u003e prompt the user for confirmation\n\u003e\n\u003e ### Types\n\u003e\n\u003e **UserDeniedError**\n\u003e An error type indicating that the application's request has been denied by\n\u003e the user\n\u003e Type: Error\n\u003e\n\u003e **Hex**\n\u003e Type: String\n\u003e Example:\n\u003e `\"0000000000000000000a24677957d1e50d70e67c513d220dbe8868c4c3aefc08\"`\n\u003e\n\u003e **Address**\n\u003e Address details\n\u003e Type: Object\n\u003e Example:\n\u003e\n\u003e ```\n\u003e {\n\u003e \"address\": \"bc1qn0fqlzamcfuahq6xuujrq08ex7e26agt20gexs\",\n\u003e \"publicKey\":\n\u003e \"02ad58c0dced71a236f4073c3b6f0ee27dde6fe96978e9a9c9500172e3f1886e5a\",\n\u003e \"derivationPath\": \"84'/1'/0'/0/0\"\n\u003e }\n\u003e ```\n\u003e\n\u003e ### API\n\u003e\n\u003e The wallet must implement the following methods.\n\u003e\n\u003e **enable**\n\u003e\n\u003e The enable call prompts the user for access to the wallet.\n\u003e\n\u003e If successful, it resolves to an address (`**Address**` type) of the\n\u003e wallet. Typically the first external address to be used as an identity.\n\u003e\n\u003e **`UserDeniedError`** will be thrown if the request is rejected.\n\u003e\n\u003e **request**\n\u003e\n\u003e The request method must take one parameter in the following format:\n\u003e\n\u003e ```\n\u003e {\n\u003e \"method\": \"wallet_methodName\",\n\u003e \"params\": [\"foo\", \"bar\", \"baz\"]\n\u003e }\n\u003e ```\n\u003e\n\u003e For a list of mandatory methods see Table\n\u003e\n\u003e The wallet should reject request calls unless `enable` has been resolved.\n\u003e\n\u003e Sensitive requests that involve signing should always prompt the user for\n\u003e confirmation\n\u003e\n\u003e On success the request should resolve to the response as defined in the\n\u003e method table.\n\u003e\n\u003e **`UserDeniedError`** will be thrown if the request is rejected.\n\u003e\n\u003e **Mandatory methods**\n\u003e\n\u003e method: `wallet_getAddresses` params: [`index = 0, numAddresses = 1, change\n\u003e = false`]\n\u003e return: `[ Address ]`\n\u003e error: UserDeniedError\n\u003e\n\u003e method: `wallet_signMessage` params: `[ message, address ]`\n\u003e return: Signature `Hex`\n\u003e error: UserDeniedError\n\u003e\n\u003e method: `wallet_signPSBT` params: `[ [psbtBase64, inputIndex, address] ]`\n\u003e return: `psbtBase64`\n\u003e error: UserDeniedError\n\u003e\n\u003e method: `wallet_getConnectedNetwork` params: `[]`\n\u003e return: Network object `mainnet` | `testnet` | `regetst`\n\u003e error: UserDeniedError\n\u003e\n\u003e ## Rationale\n\u003e\n\u003e The purpose of the API is to expose a set of commonly used wallet\n\u003e operations. In addition, it should be flexible enough to serve for other\n\u003e requests such as node RPC calls.\n\u003e\n\u003e **Why is there a singular request call instead of named methods?**\n\u003e The transport layer for the requests cannot be assumed, therefore it is\n\u003e much more flexible to instead define an abstract format.\n\u003e\n\u003e **Why are the mandatory methods so primitive? Where is getBalance,\n\u003e getUtxos, ... ?**\n\u003e A wallet need not worry about providing every possible scenario for usage.\n\u003e The primitives of keys and signing can expose enough to applications to do\n\u003e the rest. Applications should have flexibility in how they implement these\n\u003e functions. It is the role of a library rather than the wallet.\n\u003e\n\u003e ## Security Implications\n\u003e\n\u003e Great care should be taken when exposing wallet functionality externally as\n\u003e the security and privacy of the user is at risk.\n\u003e\n\u003e ### Signing\n\u003e\n\u003e Operations that trigger signing using private keys should be guarded behind\n\u003e confirmation screens where the user is fully aware of the nature of the\n\u003e transaction. In the example of a PSBT signature request, the outputs, the\n\u003e inputs and which key is being used should be clearly marked.\n\u003e\n\u003e ### Privacy\n\u003e\n\u003e Some api methods expose metadata about the user, such as public keys.\n\u003e Depending on how privacy focused the wallet intends to be, the wallet could\n\u003e protect these behind a confirmation. Commonly the wallet just needs to give\n\u003e the origin access to all of its public keys, however it could also allow\n\u003e the option to expose only selected derivation paths.\n\u003e\n\u003e -monokh",
"sig": "75e6532eb676dfe1d269e9c09ba619aba30cf10a6fc713faea414d12b0a1646ab3158587aa28d1f8a95a18bff72e2f099450a786f88bb9ce8208aca16cb5fa72"
}