feat: add Silent Payment (BIP 352) support to kind 0 profiles (#758)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: BoltTouring <BoltTouring@users.noreply.github.com>
Co-authored-by: Tanjiro <claude@tricycle.cc>
This commit is contained in:
robos 2026-03-09 11:16:08 +09:00 committed by GitHub
parent 4c144c3da1
commit 071c740145
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 131 additions and 2 deletions

View file

@ -30,6 +30,8 @@ const ProfileEditorPage = forwardRef(({ index }: { index?: number }, ref) => {
const [nip05Error, setNip05Error] = useState<string>('')
const [lightningAddress, setLightningAddress] = useState<string>('')
const [lightningAddressError, setLightningAddressError] = useState<string>('')
const [silentPaymentAddress, setSilentPaymentAddress] = useState<string>('')
const [silentPaymentAddressError, setSilentPaymentAddressError] = useState<string>('')
const [hasChanged, setHasChanged] = useState(false)
const [saving, setSaving] = useState(false)
const [uploadingBanner, setUploadingBanner] = useState(false)
@ -48,6 +50,7 @@ const ProfileEditorPage = forwardRef(({ index }: { index?: number }, ref) => {
setWebsite(profile.website ?? '')
setNip05(profile.nip05 ?? '')
setLightningAddress(profile.lightningAddress || '')
setSilentPaymentAddress(profile.sp || '')
} else {
setBanner('')
setAvatar('')
@ -56,6 +59,7 @@ const ProfileEditorPage = forwardRef(({ index }: { index?: number }, ref) => {
setWebsite('')
setNip05('')
setLightningAddress('')
setSilentPaymentAddress('')
}
}, [profile])
@ -93,6 +97,17 @@ const ProfileEditorPage = forwardRef(({ index }: { index?: number }, ref) => {
delete newProfileContent.lud16
}
if (silentPaymentAddress) {
if (silentPaymentAddress.startsWith('sp1')) {
newProfileContent.sp = silentPaymentAddress
} else {
setSilentPaymentAddressError(t('Silent Payment address must start with sp1'))
return
}
} else {
delete newProfileContent.sp
}
setSaving(true)
setHasChanged(false)
const profileDraftEvent = createProfileDraftEvent(
@ -228,6 +243,25 @@ const ProfileEditorPage = forwardRef(({ index }: { index?: number }, ref) => {
<div className="pl-3 text-xs text-destructive">{lightningAddressError}</div>
)}
</Item>
<Item>
<Label htmlFor="profile-sp-address-input">
{t('Silent Payment Address (BIP 352)')}
</Label>
<Input
id="profile-sp-address-input"
value={silentPaymentAddress}
placeholder="sp1qq..."
onChange={(e) => {
setSilentPaymentAddressError('')
setSilentPaymentAddress(e.target.value)
setHasChanged(true)
}}
className={silentPaymentAddressError ? 'border-destructive' : ''}
/>
{silentPaymentAddressError && (
<div className="pl-3 text-xs text-destructive">{silentPaymentAddressError}</div>
)}
</Item>
</div>
</SecondaryPageLayout>
)