There was a James P. Miller who was a private in the US Army. He received it for
April 2, 1865
Capture of flag of 12 Mississippi Cavalry (CSA)
There were a lot of Medal of Honors issued during the Civil War. The criteria was not the same as we have now. They were issued for capturing the enemy's flag or capturing a general or bringing ammunition.
Here is a link to his headstone.
Here is the remarks from that site:
Pvt. James Miller (1834-1918), a member of the 4th Iowa Cavalry, received the Medal of Honor for capturing the flag of the 12th Mississippi Cavalry at Selma, Alabama on April 12, 1865. Miller was from New London, Iowa but moved to York, Nebraska in 1870 and farmed, served as Sheriff of York County and as a state Senator. It is rare to have two Medal of Honor recipients in the same cemetery but John Shapland of the 104th Illinois is also buried here. He was awarded the Medal of Honor for bravery at Elk River, Tennessee on July 2, 1863. There is also a statue of a Civil War Soldier here in Greenwood Cemetery.
I found this on an ancestry site.
James P Miller, having been in the United States Union Army for about one-and-a-half years, and riding as a Private in Company "D", 4th Iowa Volunteer Cavalry Regiment was traveling and fighting in the southern states of Arkansas, Tennessee, Alabama, and Georgia. On 02 April 1865, at the battle site in and around the town of Selma, Alabama, J P Miller's unit, along with other Northern units, came face to face with a large southern contingent of rebel fighters, one group being the 12th Mississippi Cavalry.
The info states he was a Private but his headstone lists him as a Lieutenant. He may have remained in the Army and was promoted. I assume these are the same two people. I can't say if this is your ancestor.