-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display rune balances in address page #3831
Conversation
cc @cryptoni9n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this is great!
I've made some changes to help you along a bit. Since we are aggregating potentially the same runes in different outputs I added this rather complicated looking addition logic. Basically I create a Map with SpacedRunes to Pile (Amount) and if we have already encountered this rune in a previous output instead of inserting we add the balance on to the existing.
The reason the tests weren't working because you forgot to add the --index-addresses
flag to TestServer::spawn
.
I also added the symbol next to the amount.
Some tasks for you if you'd like to refine this PR:
- Send multiple different runes to the same address
- Send the same rune twice to the same address (to check that different outputs are aggregated correctly)
- We could sort the the runes lexicographically (optional)
- Add a link (href) to the Rune name in the html so a user can click on it to go to that runes etching/parameter page.
If you have any other question, don't hesitate to ask!
Thanks @raphjaph! Updated as per your comments. Definitely should have thought about aggregating the Rune balances, stupid me; I didn't sort by alphabet as I thought it we'd want to keep the client as un-opinionated as possible, but feel free to do so of course. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect PR!
LGTM
Does this also apply to the JSON api? |
* Fix type in runes docs (ordinals#3447) * Fix deploy bitcoin.conf typo (ordinals#3443) * Remove `etch` from error message (ordinals#3449) * Update rune docs for Chinese version (ordinals#3457) * Update testing.md (ordinals#3463) * Fix typo in zh.po (ordinals#3464) * Update required Rust version in README (ordinals#3466) * Add package necessary for Ubuntu (ordinals#3462) * Add rune logo and link to navbar (ordinals#3442) * Fix maturation loop (ordinals#3480) * Add wallet batch outputs and inscriptions endpoints (ordinals#3456) * Check etching commit confirmations correctly (ordinals#3507) Previously, we were checking if an etching commit transaction had matured by asking bitcoind how many confirmations it had. This was incorrect, because if ord was behind bitcoind, the number of confirmations would be based on bitcoind's current block height, and would be greater than the number of confirmations the commit transaction had as of the reveal transaction block height. This commit fixes this by calculating the number of confirmations using the block height of the commit transaction, which is correct even if bitcoind is ahead. * Show decimal rune balances (ordinals#3505) * Allow inscribing without file (ordinals#3451) This allows inscribing only the delegate without having to specify a file. In the batch it allows you to comletely omit the file as well. * Add etching turbo flag (ordinals#3511) Future runes features may be opt-in, for example, if they increase light client validation costs, or if they are simply too degenerate. This commit adds a "turbo" flag, which, if set, premptively opts in to such future features. It also sets the "turbo" flag on the genesis rune, UNCOMMON•GOODS. Because the genesis rune is inserted into the index when it is created, the schema version is also incremented, to force rebuilding indices created before this commit. * Update data carriersize to match with ord (ordinals#3506) * Document allowed opcodes in runestones (ordinals#3461) Document that data push opcodes 0 through 78 inclusive are allowed in runestones, and opcodes 79 and above will produce a cenotaph. Also add a test that makes sure that this is actually true. * Fix typo in zh.po (ordinals#3498) * Better error message when bitcoind doesn't start (ordinals#3500) * Updated rust-version to 1.74.0 (ordinals#3492) Ord now requires Rust 1.74 to build, update `rust-version` in Cargo.toml files to reflect this. * Mint with destination (ordinals#3497) * Bump ord crate required rust version to 1.76 (ordinals#3512) * Add postage flag to mint command (ordinals#3482) * Test that mints without a cap are unmintable (ordinals#3495) Test that if the `cap` field of an etching is unset, it is treated as being zero, and the rune is unmintable.Test that if the `cap` field of an etching is unset, it is treated as being zero, and the rune is unmintable. * Release 0.18.0 (ordinals#3513) - Bump version: 0.17.1 → 0.18.0 - Update changelog - Update changelog contributor credits - Update dependencies * Fix off-by-one in wallet when waiting for etching commitment to mature (ordinals#3515) While waiting to broadcast a rune etching, take into account the fact that the commit transaction will have an additional confirmation in the next block. Previously we weren't, so the wallet was waiting for one confirmation too many. * Release 0.18.1 (ordinals#3522) - Bump version: 0.18.0 → 0.18.1 - Update changelog - Update changelog contributor credits * Forbid etching below rune activation height (ordinals#3523) Don't allow etching if the etching reveal height is below the runes activation height, otherwise the user would waste funds on an ineffective etching. * Put rune higher on /inscription (ordinals#3363) * Fix typo in recursion docs (ordinals#3529) * Add Red Had build instructions to readme (ordinals#3531) * Add runes pagination (ordinals#3215) * Lookup rune by number (ordinals#3440) * Emit rune-related events (ordinals#3219) Emit rune etched, rune minted, rune transferred, and rune burned events to the index event channel. * Address runes review comments (ordinals#3547) - Fix overflow in Rune::from_str - Use checked_pow in Pile Display implementation - Only report first flaw in cenotaph - Add comment to Edict::from_integers for output == tx.output.len() - Avoid divide by zero in RuneUpdater - Add test for zero rune ID delta - Make varint::decode return a Result instead of an Option * Lock runes commit output (ordinals#3504) * Display etched runes on /block (ordinals#3366) * Remove /runes/balances page (ordinals#3555) * Fix typo in zh.po (ordinals#3540) * Fix typos (ordinals#3541) * Store wallets in /wallets subdir of data dir (ordinals#3553) Makes the data dir cleaner, and avoids a conflict with wallet named `index`, since there's already an `index.redb`. * Add command to export BIP-329 labels for wallet outputs (ordinals#3120) Add `ord wallet label`, which exports BIP-320 wallet output labels. Especially useful for labeling outputs in Sparrow wallets. * Add open mint tests (ordinals#3558) * Document turbo flag (ordinals#3579) * Release 0.18.2 (ordinals#3582) - Bump version: 0.18.1 → 0.18.2 - Update changelog - Update changelog contributor credits - Update dependencies * Bump ord version to 0.18.2 in Cargo.toml (ordinals#3583) * Resume cycles through all pending etchings (ordinals#3566) * Generate sample batch.yaml in env command (ordinals#3530) * Add default content proxy and decompress to env command (ordinals#3509) * Address runes review comments (ordinals#3605) - Use inclusive range in Index::get_runes_in_block - Remove out-of-date comment - Use checked_pow in Decimal Display impl - Use checked_pow in impl FromStr for Decimal * Remove duplicated word (ordinals#3598) * Show premine percentage (ordinals#3567) * Add back runes balances API (ordinals#3571) * Remove timeout for wallet client (ordinals#3621) * Add `dry-run` flag to `resume` command (ordinals#3592) * Clear etching when rune commitment is spent (ordinals#3618) * Add test Rune cannot be minted less than limit amount (ordinals#3556) * Update recursion.md with consistant syntax (ordinals#3585) * Check rune minimum at height before sending (ordinals#3626) * Release 0.18.3 (ordinals#3625) * Update sparrow-wallet.md --name flag update (ordinals#3635) * Fix zh.po translations (ordinals#3588) * Allow minting if mint begins next block (ordinals#3659) Make `ord wallet mint` check whether the rune to be minted is mintable in the next block, since that's the block in which our mint transaction might actually be mined. * Do not show runic outputs in cardinals command (ordinals#3656) * Update sat-hunting.md with how to transfer specific sats (ordinals#3666) * Allow longer request body for JSON API (ordinals#3655) * Clarify that inscriptions must be served from URLs with path /content/<INSCRIPTION_ID> (ordinals#3209) In order for inscriptions to retrieve their own inscription ID, inscription content must be served from URLs with path `/content/<INSCRIPTION_ID>`. When an inscription with ID X delegates to another inscription with ID Y, meaning that X has a delegate field whose value is Y, when requesting the content of inscription ID X, the content of inscription Y must be returned from the URL with path `/content/X`. This allows inscription Y to use the ID of delegating inscriptions as seeds for generative content, since the delegating inscriptions will all have different inscription IDs. * Use contains_key instead of get / is_some (ordinals#3705) * Fix typo on sat hunting page (ordinals#3668) * Add support for mjs files (ordinals#3653) * Use correct content type for .mjs inscriptions (ordinals#3712) `text/javascript` is the preferred MIME type for JavaScript, so use it instead of `application/x-javascript` when inscribing `.mjs` files. * Remove duplicate endpoint from explorer.md (ordinals#3716) Output `/output/<OUTPOINT>` was listed twice. * Persist config files for ord env command (ordinals#3715) * Add alt text to preview image (ordinals#3713) * Fix send runes (ordinals#3484) * Release 0.18.4 (ordinals#3720) - Bump version: 0.18.3 → 0.18.4 - Update changelog - Update changelog contributor credits - Update dependencies * Show progress bar for etching (ordinals#3673) * Bump rustfmt version 2018 to 2021 (ordinals#3721) * Patch some omissions in the Chinese translation (ordinals#3694) * Update runes.md docs (ordinals#3681) * Update sat-hunting.md (ordinals#3724) * Allow higher rpcworkqueue limit conf (ordinals#3615) * Allow specifying different output formats (ordinals#3424) * Release 0.18.5 (ordinals#3741) * Update index.rs to fix ord list command (ordinals#3762) * Add `ord wallet runics` command (ordinals#3734) * Clarify teleburning.md (ordinals#3744) * Allow postage equal to dust limit in mint.rs (ordinals#3756) * Update runes spec (ordinals#3745) * Fix fuzz testers (ordinals#3740) * Add command to list pending etchings (ordinals#3732) * Enable resuming a specific rune etching (ordinals#3679) * Add decode api (ordinals#3733) * Make settings public (ordinals#3768) * Index addresses (ordinals#3757) * Add parents recursive endpoint (ordinals#3749) * Remove duplicate example (ordinals#3776) * Add /inscription/:query/:child_number route (ordinals#3777) * Add mint progress field to rune.html (ordinals#3748) * Add feerate percentiles to blockinfo endpoint (ordinals#3753) * Update `ord list` to include inscriptions and runes information (ordinals#3766) * Add delegate value to recursive inscription endpoint (ordinals#3751) * Fix old conflicts * Resolve issues with Ordzaar modifications * Remove duplicate /inscriptions endpoint * Add recursive endpoint with more details about children (ordinals#3771) * Fix panic in ord env shutdown (ordinals#3787) * Make recursive endpoints proxiable (ordinals#3797) * Make settings public (ordinals#3800) * Link address on inscription.html (ordinals#3801) * Link address on output & tx (ordinals#3799) * Add --http-port to settings yaml (ordinals#3796) * Add sat balance to address page (ordinals#3810) * Make Index public (ordinals#3807) * Add -dev suffix to version (ordinals#3812) * Add all transaction hex to block json response (ordinals#3805) * Add public `shut_down()` function (ordinals#3811) * Add typed errors with `snafu` (ordinals#3832) * Add debugging tips README (ordinals#3823) * Add sat name to inscription page (ordinals#3826) * Add sat ranges to output (ordinals#3817) * Add --all flag on `ord wallet sats` (ordinals#3824) * Display aggregated rune balances in address page (ordinals#3831) * Update Spanish Translation (ordinals#3835) * Add charm to burned inscriptions (ordinals#3836) * Add ability to cancel shutdown (ordinals#3820) * Add inscriptions to address page (ordinals#3843) * Release 0.19.0 (ordinals#3844) - Bump version: 0.18.5 → 0.19.0 - Update changelog - Update changelog contributor credits - Update dependencies * Update index method name --------- Co-authored-by: twosatsmaxi <112330467+twosatsmaxi@users.noreply.github.com> Co-authored-by: bitspill <github@bitspill.net> Co-authored-by: Ordinarius <137325073+ordinariusprof@users.noreply.github.com> Co-authored-by: Dr.JingLee <95461562+DrJingLee@users.noreply.github.com> Co-authored-by: gmart7t2 <49558347+gmart7t2@users.noreply.github.com> Co-authored-by: RandolphJiffy <RandolphJiffy@hotmail.com> Co-authored-by: nine <118634361+cryptoni9n@users.noreply.github.com> Co-authored-by: Petrius Lima <petrius.lima@gmail.com> Co-authored-by: 0xLugon <lugon@alphatrue.com> Co-authored-by: raph <raphjaph@protonmail.com> Co-authored-by: Casey Rodarmor <casey@rodarmor.com> Co-authored-by: tgscan-dev <136890925+tgscan-dev@users.noreply.github.com> Co-authored-by: ynohtna92 <ynohtna92@users.noreply.github.com> Co-authored-by: nix.eth <113411347+nix-eth@users.noreply.github.com> Co-authored-by: rongyi <sqrongyi@163.com> Co-authored-by: Felipe Lincoln <mail.felipelincoln@gmail.com> Co-authored-by: blackj <yuan_gou@hotmail.com> Co-authored-by: StevenMia <166844090+StevenMia@users.noreply.github.com> Co-authored-by: Javier Villanueva <javiervd@gmail.com> Co-authored-by: oxSaturn <oxSaturn@proton.me> Co-authored-by: zmeyer44 <54515037+zmeyer44@users.noreply.github.com> Co-authored-by: Taha Abbasi <taha.abbasi@ferrum.network> Co-authored-by: losingle <losingle@gmail.com> Co-authored-by: Vannix <134819232+Vanniix@users.noreply.github.com> Co-authored-by: knowmost <167442703+knowmost@users.noreply.github.com> Co-authored-by: Eloc <42568538+elocremarc@users.noreply.github.com> Co-authored-by: bingryan <41174435+bingryan@users.noreply.github.com> Co-authored-by: AM shadow <154503348+shadowv0vshadow@users.noreply.github.com> Co-authored-by: Han Tuzun <hantuzun@users.noreply.github.com> Co-authored-by: Jeremy Rubin <j@rubin.io> Co-authored-by: Luis Aguilar <ldiego08@gmail.com> Co-authored-by: Jeason <me@cowpoke.cc> Co-authored-by: phorkish <164674569+phorkish@users.noreply.github.com> Co-authored-by: Daniel <daniel@adip.me> Co-authored-by: benbuschmann <ben@rootnaturally.com> Co-authored-by: thewrlck <138235209+thewrlck@users.noreply.github.com> Co-authored-by: Nick <113782315+nick07002@users.noreply.github.com> Co-authored-by: Young <63138174+yoitsyoung@users.noreply.github.com> Co-authored-by: Zerone495 <62160815+Zerone495@users.noreply.github.com> Co-authored-by: onchainguy <1436535+onchainguy-btc@users.noreply.github.com>
I believe the address JSON-RPC endpoint only returns a list of outputs currently, @raphjaph I was thinking we can serialize the AddressHtml struct and pass it into the response? |
Hi! First ever public pull request 🙏 Please feedback is welcome
Referencing issue #3809 to add more information to address page. I also refactored the tests on templates/address.rs so that different categories of address information are tested separately.
Unfortunately, I'm not able to get the integration at tests/server.rs to work; it seems to be that rune commands are not compatible with the mockcore::spawn() handle, hence it is necessary to enforce the transaction on regtest; however I get a 404 error when requesting pages with a regtest address format; so the test currently always fails.