Add Faucet endpoint (#36)

* Add internal methods for faucet feature

* Add grpc handler

* Lint
This commit is contained in:
Pietralberto Mazza
2023-12-04 16:40:56 +01:00
committed by GitHub
parent 6344005785
commit 9e9e61fb89
9 changed files with 567 additions and 181 deletions

View File

@@ -148,14 +148,22 @@ func (m *forfeitTxsMap) push(txs []string) {
}
}
func (m *forfeitTxsMap) sign(txid, tx string) error {
func (m *forfeitTxsMap) sign(txs []string) error {
m.lock.Lock()
defer m.lock.Unlock()
if _, ok := m.forfeitTxs[txid]; !ok {
return fmt.Errorf("forfeit tx %s not found ", txid)
for _, tx := range txs {
ptx, err := psetv2.NewPsetFromBase64(tx)
if err != nil {
return fmt.Errorf("invalid forfeit tx format")
}
utx, _ := ptx.UnsignedTx()
txid := utx.TxHash().String()
if _, ok := m.forfeitTxs[txid]; !ok {
return fmt.Errorf("forfeit tx %s not found", txid)
}
m.forfeitTxs[txid].signed = true
}
m.forfeitTxs[txid].signed = true
return nil
}