templates/withdrawal.html
<form action="/sent" method="post" class=""> <input type="hidden" name="time" id="time" value=""> <input type="hidden" name="sender" value="{{address}}"> <div class="mb-3"> <label for="receiver" class="form-label">送付先アドレス</label> <input type="text" class="form-control" id="receiver" name="receiver" placeholder="送付先のアドレスを入力してください"> </div> <div class="mb-3"> <label for="amount" class="form-label">送付コイン量</label> <input type="text" class="form-control" id="amount" name="amount" placeholder="数量を半角数字で入力してください。e.g. 1000"> </div> <input type="submit" value="送信" class="btn btn-primary"/> </form>
#[derive(Serialize, Deserialize, Debug)] struct UnsignedTransaction { time: String, sender: String, receiver: String, amount: i32, } // async fn handle_sent(axum::Form(unsignedtransaction): axum::Form<UnsignedTransaction>) -> axum::response::Html<String> { let tera = tera::Tera::new("templates/*").unwrap(); let mut context = tera::Context::new(); context.insert("time", &unsignedtransaction.time); context.insert("receiver", &unsignedtransaction.receiver); context.insert("amount", &unsignedtransaction.amount); let output = tera.render("sent.html", &context); axum::response::Html(output.unwrap()) }
formのPOSTはできました。
このデータを受け取ったタイミングで、外部のIP(node)に合わせてPOSTしたい。