mirror of
https://github.com/aljazceru/hypergolic.git
synced 2025-12-19 06:24:20 +01:00
problem: can't use multiple bitcoin addresses for a single pubkey
This commit is contained in:
@@ -21,17 +21,24 @@
|
||||
_associationRequests?.unsubscribe();
|
||||
});
|
||||
|
||||
let addresses = new Map<string, BitcoinAssociation>()
|
||||
let addresses = new Map<string, BitcoinAssociation>();
|
||||
|
||||
onMount(()=>{
|
||||
addresses = rocket.BitcoinAssociations()
|
||||
addresses.forEach(a => {
|
||||
onMount(() => {
|
||||
addresses = rocket.BitcoinAssociations();
|
||||
addresses.forEach((a) => {
|
||||
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>
|
||||
|
||||
<Card.Root class="sm:col-span-3">
|
||||
@@ -51,18 +58,18 @@
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{#each addresses as [pubkey, ba], _ (pubkey)}
|
||||
{#each addresses as [address, ba], _ (address)}
|
||||
<Table.Row>
|
||||
<Table.Cell>
|
||||
<div class="flex flex-nowrap">
|
||||
<Avatar
|
||||
ndk={$ndk}
|
||||
pubkey={pubkey}
|
||||
pubkey={ba.Pubkey}
|
||||
class="h-10 w-10 flex-none rounded-full object-cover"
|
||||
/>
|
||||
<Name
|
||||
ndk={$ndk}
|
||||
pubkey={pubkey}
|
||||
pubkey={ba.Pubkey}
|
||||
class="hidden max-w-32 truncate p-2 md:inline-block"
|
||||
/>
|
||||
</div>
|
||||
@@ -71,7 +78,6 @@
|
||||
{ba.Balance.toLocaleString()}
|
||||
</Table.Cell>
|
||||
<Table.Cell class="table-cell">{ba.Address}</Table.Cell>
|
||||
|
||||
</Table.Row>
|
||||
{/each}
|
||||
</Table.Body>
|
||||
|
||||
@@ -91,15 +91,18 @@
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>Subscribe for Updates</Dialog.Title>
|
||||
<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>
|
||||
<div class="flex flex-col gap-4 py-4">
|
||||
{#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}
|
||||
<Login />
|
||||
{/if}
|
||||
<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">
|
||||
<Label for="email" class="text-right">Email</Label>
|
||||
<Input bind:value={email} id="email" placeholder="Your email" class="col-span-3" />
|
||||
@@ -109,7 +112,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
<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.Content>
|
||||
|
||||
@@ -5,17 +5,20 @@ import validate from 'bitcoin-address-validation';
|
||||
import { BitcoinTipTag, bitcoinTip, txs } from '@/stores/bitcoin';
|
||||
|
||||
export class Rocket {
|
||||
UpsertBitcoinAssociation(association: BitcoinAssociation): NDKEvent {
|
||||
Event: NDKEvent;
|
||||
UpsertBitcoinAssociation(association: BitcoinAssociation): NDKEvent | undefined {
|
||||
let event: NDKEvent | undefined = undefined;
|
||||
if (true) {
|
||||
//todo: check if exists
|
||||
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);
|
||||
if (association.Validate()) {
|
||||
let existing = this.BitcoinAssociations().get(association.Address!);
|
||||
if ((existing && existing.Pubkey != association.Pubkey) || !existing) {
|
||||
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;
|
||||
}
|
||||
@@ -29,14 +32,17 @@ export class Rocket {
|
||||
ba.Address = split[1];
|
||||
ba.Pubkey = split[0];
|
||||
if (ba.Validate()) {
|
||||
a.set(ba.Pubkey, ba);
|
||||
a.set(ba.Address, ba);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
Event: NDKEvent;
|
||||
UpsertMeritTransfer(): NDKEvent | undefined {
|
||||
let event: NDKEvent | undefined = undefined;
|
||||
return event;
|
||||
}
|
||||
|
||||
URL(): string {
|
||||
let ignitionID = undefined;
|
||||
@@ -419,7 +425,7 @@ export class RocketAMR {
|
||||
LeadTime: number;
|
||||
LeadTimeUpdate: number;
|
||||
Merits: number;
|
||||
Extra: {eventAMR: AMRAuction};
|
||||
Extra: { eventAMR: AMRAuction };
|
||||
SatsOwed(): number {
|
||||
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 {
|
||||
AMRIDs: string[];
|
||||
@@ -632,12 +643,8 @@ export class AMRAuction {
|
||||
Merits: number;
|
||||
Event: NDKEvent;
|
||||
Extra: { rocket: Rocket };
|
||||
Status(
|
||||
rocket: Rocket,
|
||||
bitcoinTip: number,
|
||||
transactions?: txs
|
||||
): AMRAuctionStatus {
|
||||
let status:AMRAuctionStatus = "PENDING"
|
||||
Status(rocket: Rocket, bitcoinTip: number, transactions?: txs): AMRAuctionStatus {
|
||||
let status: AMRAuctionStatus = 'PENDING';
|
||||
if (transactions && transactions.Address != this.RxAddress) {
|
||||
throw new Error('invalid address');
|
||||
}
|
||||
@@ -663,17 +670,14 @@ export class AMRAuction {
|
||||
pending.RxAddress == this.RxAddress &&
|
||||
pending.AMRIDs[0] == this.AMRIDs[0] //todo: check whole array
|
||||
) {
|
||||
found = true
|
||||
if (status == "CHECKING MEMPOOL") {
|
||||
if (
|
||||
Math.floor(new Date().getTime() / 1000) < transactions.LastUpdate + 60000
|
||||
) {
|
||||
found = true;
|
||||
if (status == 'CHECKING MEMPOOL') {
|
||||
if (Math.floor(new Date().getTime() / 1000) < transactions.LastUpdate + 60000) {
|
||||
status = 'OPEN';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -805,6 +809,7 @@ export class BitcoinAssociation {
|
||||
Event: NDKEvent;
|
||||
Balance: number;
|
||||
Validate(): boolean {
|
||||
console.log(819, this);
|
||||
let valid = true;
|
||||
if (this.Pubkey.length != 64) {
|
||||
valid = false;
|
||||
|
||||
Reference in New Issue
Block a user