mirror of
https://github.com/aljazceru/hypergolic.git
synced 2025-12-20 06:54:19 +01:00
problem: can't use multiple bitcoin addresses for a single pubkey
This commit is contained in:
@@ -21,17 +21,24 @@
|
|||||||
_associationRequests?.unsubscribe();
|
_associationRequests?.unsubscribe();
|
||||||
});
|
});
|
||||||
|
|
||||||
let addresses = new Map<string, BitcoinAssociation>()
|
let addresses = new Map<string, BitcoinAssociation>();
|
||||||
|
|
||||||
onMount(()=>{
|
onMount(() => {
|
||||||
addresses = rocket.BitcoinAssociations()
|
addresses = rocket.BitcoinAssociations();
|
||||||
addresses.forEach(a => {
|
addresses.forEach((a) => {
|
||||||
if (a.Address) {
|
if (a.Address) {
|
||||||
getBalance(a.Address).then(v=>{a.Balance = v; addresses.set(a.Pubkey, a); addresses = addresses}).catch(err=>{console.log(err)})
|
getBalance(a.Address)
|
||||||
|
.then((v) => {
|
||||||
|
a.Balance = v;
|
||||||
|
addresses.set(a.Address!, a);
|
||||||
|
addresses = addresses;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card.Root class="sm:col-span-3">
|
<Card.Root class="sm:col-span-3">
|
||||||
@@ -51,18 +58,18 @@
|
|||||||
</Table.Row>
|
</Table.Row>
|
||||||
</Table.Header>
|
</Table.Header>
|
||||||
<Table.Body>
|
<Table.Body>
|
||||||
{#each addresses as [pubkey, ba], _ (pubkey)}
|
{#each addresses as [address, ba], _ (address)}
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
<div class="flex flex-nowrap">
|
<div class="flex flex-nowrap">
|
||||||
<Avatar
|
<Avatar
|
||||||
ndk={$ndk}
|
ndk={$ndk}
|
||||||
pubkey={pubkey}
|
pubkey={ba.Pubkey}
|
||||||
class="h-10 w-10 flex-none rounded-full object-cover"
|
class="h-10 w-10 flex-none rounded-full object-cover"
|
||||||
/>
|
/>
|
||||||
<Name
|
<Name
|
||||||
ndk={$ndk}
|
ndk={$ndk}
|
||||||
pubkey={pubkey}
|
pubkey={ba.Pubkey}
|
||||||
class="hidden max-w-32 truncate p-2 md:inline-block"
|
class="hidden max-w-32 truncate p-2 md:inline-block"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,7 +78,6 @@
|
|||||||
{ba.Balance.toLocaleString()}
|
{ba.Balance.toLocaleString()}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell class="table-cell">{ba.Address}</Table.Cell>
|
<Table.Cell class="table-cell">{ba.Address}</Table.Cell>
|
||||||
|
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
{/each}
|
{/each}
|
||||||
</Table.Body>
|
</Table.Body>
|
||||||
|
|||||||
@@ -91,15 +91,18 @@
|
|||||||
<Dialog.Header>
|
<Dialog.Header>
|
||||||
<Dialog.Title>Subscribe for Updates</Dialog.Title>
|
<Dialog.Title>Subscribe for Updates</Dialog.Title>
|
||||||
<Dialog.Description>
|
<Dialog.Description>
|
||||||
Subscribe via DM or email and we'll ping you when there are new releases/features
|
Subscribe now and we'll ping you when there are new releases/features
|
||||||
</Dialog.Description>
|
</Dialog.Description>
|
||||||
<div class="flex flex-col gap-4 py-4">
|
<div class="flex flex-col gap-4 py-4">
|
||||||
{#if $currentUser}
|
{#if $currentUser}
|
||||||
<Button on:click={Subscribe}>I use nostr, please DM me with updates</Button>
|
<Button on:click={Subscribe}>DM me with updates</Button>
|
||||||
{:else}
|
{:else}
|
||||||
<Login />
|
<Login />
|
||||||
{/if}
|
{/if}
|
||||||
<Separator />
|
<Separator />
|
||||||
|
<span class="ml-auto mr-auto flex"
|
||||||
|
>If you don't use nostr, you can subscribe to updates with an email address instead</span
|
||||||
|
>
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
<div class="grid grid-cols-4 items-center gap-4">
|
||||||
<Label for="email" class="text-right">Email</Label>
|
<Label for="email" class="text-right">Email</Label>
|
||||||
<Input bind:value={email} id="email" placeholder="Your email" class="col-span-3" />
|
<Input bind:value={email} id="email" placeholder="Your email" class="col-span-3" />
|
||||||
@@ -109,7 +112,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<Button disabled={emailInValid} on:click={SubmitEmailAndSubscribe}
|
<Button disabled={emailInValid} on:click={SubmitEmailAndSubscribe}
|
||||||
>I don't use nostr yet, please email me with updates</Button
|
>Please email me with updates</Button
|
||||||
>
|
>
|
||||||
</Dialog.Header>
|
</Dialog.Header>
|
||||||
</Dialog.Content>
|
</Dialog.Content>
|
||||||
|
|||||||
@@ -5,17 +5,20 @@ import validate from 'bitcoin-address-validation';
|
|||||||
import { BitcoinTipTag, bitcoinTip, txs } from '@/stores/bitcoin';
|
import { BitcoinTipTag, bitcoinTip, txs } from '@/stores/bitcoin';
|
||||||
|
|
||||||
export class Rocket {
|
export class Rocket {
|
||||||
UpsertBitcoinAssociation(association: BitcoinAssociation): NDKEvent {
|
Event: NDKEvent;
|
||||||
|
UpsertBitcoinAssociation(association: BitcoinAssociation): NDKEvent | undefined {
|
||||||
let event: NDKEvent | undefined = undefined;
|
let event: NDKEvent | undefined = undefined;
|
||||||
if (true) {
|
if (association.Validate()) {
|
||||||
//todo: check if exists
|
let existing = this.BitcoinAssociations().get(association.Address!);
|
||||||
this.PrepareForUpdate();
|
if ((existing && existing.Pubkey != association.Pubkey) || !existing) {
|
||||||
event = new NDKEvent(this.Event.ndk, this.Event.rawEvent());
|
this.PrepareForUpdate();
|
||||||
event.created_at = Math.floor(new Date().getTime() / 1000);
|
event = new NDKEvent(this.Event.ndk, this.Event.rawEvent());
|
||||||
event.tags.push(['address', `${association.Pubkey}:${association.Address}`]);
|
event.created_at = Math.floor(new Date().getTime() / 1000);
|
||||||
event.tags.push(['proof_full', JSON.stringify(association.Event.rawEvent())]);
|
event.tags.push(['address', `${association.Pubkey}:${association.Address}`]);
|
||||||
updateIgnitionAndParentTag(event);
|
event.tags.push(['proof_full', JSON.stringify(association.Event.rawEvent())]);
|
||||||
updateBitcoinTip(event);
|
updateIgnitionAndParentTag(event);
|
||||||
|
updateBitcoinTip(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
@@ -29,14 +32,17 @@ export class Rocket {
|
|||||||
ba.Address = split[1];
|
ba.Address = split[1];
|
||||||
ba.Pubkey = split[0];
|
ba.Pubkey = split[0];
|
||||||
if (ba.Validate()) {
|
if (ba.Validate()) {
|
||||||
a.set(ba.Pubkey, ba);
|
a.set(ba.Address, ba);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
Event: NDKEvent;
|
UpsertMeritTransfer(): NDKEvent | undefined {
|
||||||
|
let event: NDKEvent | undefined = undefined;
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
URL(): string {
|
URL(): string {
|
||||||
let ignitionID = undefined;
|
let ignitionID = undefined;
|
||||||
@@ -419,7 +425,7 @@ export class RocketAMR {
|
|||||||
LeadTime: number;
|
LeadTime: number;
|
||||||
LeadTimeUpdate: number;
|
LeadTimeUpdate: number;
|
||||||
Merits: number;
|
Merits: number;
|
||||||
Extra: {eventAMR: AMRAuction};
|
Extra: { eventAMR: AMRAuction };
|
||||||
SatsOwed(): number {
|
SatsOwed(): number {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -619,7 +625,12 @@ export async function ValidateZapPublisher(rocket: NDKEvent, zap: NDKEvent): Pro
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
type AMRAuctionStatus = 'PENDING' | 'OPEN' | 'TX DETECTED' | 'SOLD & PENDING RATIFICATION' | 'CHECKING MEMPOOL';
|
type AMRAuctionStatus =
|
||||||
|
| 'PENDING'
|
||||||
|
| 'OPEN'
|
||||||
|
| 'TX DETECTED'
|
||||||
|
| 'SOLD & PENDING RATIFICATION'
|
||||||
|
| 'CHECKING MEMPOOL';
|
||||||
|
|
||||||
export class AMRAuction {
|
export class AMRAuction {
|
||||||
AMRIDs: string[];
|
AMRIDs: string[];
|
||||||
@@ -632,12 +643,8 @@ export class AMRAuction {
|
|||||||
Merits: number;
|
Merits: number;
|
||||||
Event: NDKEvent;
|
Event: NDKEvent;
|
||||||
Extra: { rocket: Rocket };
|
Extra: { rocket: Rocket };
|
||||||
Status(
|
Status(rocket: Rocket, bitcoinTip: number, transactions?: txs): AMRAuctionStatus {
|
||||||
rocket: Rocket,
|
let status: AMRAuctionStatus = 'PENDING';
|
||||||
bitcoinTip: number,
|
|
||||||
transactions?: txs
|
|
||||||
): AMRAuctionStatus {
|
|
||||||
let status:AMRAuctionStatus = "PENDING"
|
|
||||||
if (transactions && transactions.Address != this.RxAddress) {
|
if (transactions && transactions.Address != this.RxAddress) {
|
||||||
throw new Error('invalid address');
|
throw new Error('invalid address');
|
||||||
}
|
}
|
||||||
@@ -663,17 +670,14 @@ export class AMRAuction {
|
|||||||
pending.RxAddress == this.RxAddress &&
|
pending.RxAddress == this.RxAddress &&
|
||||||
pending.AMRIDs[0] == this.AMRIDs[0] //todo: check whole array
|
pending.AMRIDs[0] == this.AMRIDs[0] //todo: check whole array
|
||||||
) {
|
) {
|
||||||
found = true
|
found = true;
|
||||||
if (status == "CHECKING MEMPOOL") {
|
if (status == 'CHECKING MEMPOOL') {
|
||||||
if (
|
if (Math.floor(new Date().getTime() / 1000) < transactions.LastUpdate + 60000) {
|
||||||
Math.floor(new Date().getTime() / 1000) < transactions.LastUpdate + 60000
|
|
||||||
) {
|
|
||||||
status = 'OPEN';
|
status = 'OPEN';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -805,6 +809,7 @@ export class BitcoinAssociation {
|
|||||||
Event: NDKEvent;
|
Event: NDKEvent;
|
||||||
Balance: number;
|
Balance: number;
|
||||||
Validate(): boolean {
|
Validate(): boolean {
|
||||||
|
console.log(819, this);
|
||||||
let valid = true;
|
let valid = true;
|
||||||
if (this.Pubkey.length != 64) {
|
if (this.Pubkey.length != 64) {
|
||||||
valid = false;
|
valid = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user