diff --git a/src/components/AssociateBitcoinAddress.svelte b/src/components/AssociateBitcoinAddress.svelte index 2fadc1f..8af22e7 100644 --- a/src/components/AssociateBitcoinAddress.svelte +++ b/src/components/AssociateBitcoinAddress.svelte @@ -1,18 +1,32 @@ + - Associate Bitcoin Address + Your Bitcoin Addresses -
- You must associate at least one Bitcoin address with your npub before you can pay a Contributor. Merit purchases from this address will be associated with your pubkey. -
-
-
-
\ No newline at end of file +
+ Merit purchases must be conducted with a Bitcoin address that is associated with your pubkey, + otherwise you will not recieve the Merits upon payment. +
+ {#if $associatedAddresses.size == 0}You do not have any registered addresses{:else} + Your registered addresses: + + {/if} + Add a new address now +
+ +
+ + diff --git a/src/lib/event_helpers/rockets.ts b/src/lib/event_helpers/rockets.ts index b2ce740..2d16da1 100644 --- a/src/lib/event_helpers/rockets.ts +++ b/src/lib/event_helpers/rockets.ts @@ -1,8 +1,8 @@ -import { NDKEvent, type NDKTag } from '@nostr-dev-kit/ndk'; -import { MapOfVotes, MeritRequest, Votes } from './merits'; import { getAuthorizedZapper } from '@/helpers'; +import { BitcoinTipTag, txs } from '@/stores/bitcoin'; +import { NDKEvent, type NDKTag } from '@nostr-dev-kit/ndk'; import validate from 'bitcoin-address-validation'; -import { BitcoinTipTag, bitcoinTip, txs } from '@/stores/bitcoin'; +import { MapOfVotes, MeritRequest, Votes } from './merits'; export class Rocket { Event: NDKEvent; @@ -41,6 +41,13 @@ export class Rocket { } UpsertMeritTransfer(): NDKEvent | undefined { let event: NDKEvent | undefined = undefined; + this.PrepareForUpdate(); + event = new NDKEvent(this.Event.ndk, this.Event.rawEvent()); + event.created_at = Math.floor(new Date().getTime() / 1000); + event.tags.push(['address', `${association.Pubkey}:${association.Address}`]); + event.tags.push(['proof_full', JSON.stringify(association.Event.rawEvent())]); + updateIgnitionAndParentTag(event); + updateBitcoinTip(event); return event; } diff --git a/src/routes/buymerits/+page.svelte b/src/routes/buymerits/+page.svelte index 1d9b6f4..d786d84 100644 --- a/src/routes/buymerits/+page.svelte +++ b/src/routes/buymerits/+page.svelte @@ -111,26 +111,45 @@ if (t) console.log(t); }); + let nostrocket = derived(rockets, ($rockets) => { + let rocket: Rocket | undefined = undefined; + for (let r of $rockets) { + if ( + r.Name() == 'NOSTROCKET' && + r.Event.pubkey == 'd91191e30e00444b942c0e82cad470b32af171764c2275bee0bd99377efd4075' + ) { + //we consume the current list of bitcoin addresses from Nostrocket as a service so that users don't need to add a new address for every rocket + //todo: make this dependent on votepower not my pubkey + //todo: also allow rockets to have their own list of addresses so they can be used without nostrocket + rocket = r; + } + } + return rocket; + }); + transactions.subscribe((t) => {}); - let noAssociatedBitcoinAddress = derived( - [currentUser, pendingSales], - ([$currentUser, $pendingSales]) => { - let show = false; - if ($currentUser) { - for (let [r, a] of $pendingSales) { - if (a.length > 0 && !r.BitcoinAssociations().get($currentUser.pubkey)) { - console.log($currentUser.pubkey, r.Name()); - show = true; - } - } - } - return show; - } - ); + // let noAssociatedBitcoinAddress = derived( + // [currentUser, pendingSales], + // ([$currentUser, $pendingSales]) => { + // let show = false; + // if ($currentUser) { + // for (let [r, a] of $pendingSales) { + // if (a.length > 0) { + // let show = true + // for (let [_, ba] of r.BitcoinAssociations()) { + + // } + // } + // } + // } + // return show; + // } + // ); -{#if $noAssociatedBitcoinAddress}{/if} +{#if $nostrocket} +{/if} {#if $currentUser} {#each $pendingSales as [rocket, amr] (rocket.Event.id)}